-
Notifications
You must be signed in to change notification settings - Fork 2
Home
RK0 is built for MCU-based control systems where deterministic behaviour is critical. Determinism and clear semantics are core design guidelines.
-
It provides an O(1) preemptive priority-based scheduler. The
choose-nextalgorithm takes ~4 cycles on ARMv7m and ~11 cycles on ARMv6M. -
The kernel mechanisms allows for two complementary programming paradigms:
-
Shared-memory (procedural) – tasks synchronise via semaphores/mutexes, event flags and condition variables to share data and coordinate execution. Remarkably, mutexes support fully transitive priority inheritance.
-
Message-passing – tasks exchange data through message queues, ports, and mailboxes, between 'isolated' contexts.
-
Message Queues are flexible providing blocking or non-blocking, first or last-message semantics, and along with the scheduler policy suits event-based design patterns (e.g., the actor model).
-
Ports leverage priority boosting/demotion for synchronous client-server model.
-
-
-
The Most-Recent Message Protocol is a 1-to-many, purpose-built message-passing mechanism for control-loops.
-
Well-proven fixed-size Memory Allocator avoids fragmentation and unpredictable memory latency (O(1)).
-
Timers (delay, periodic, bounded waiting and callout) are optimised for precision and low-overhead (O(1)).
-
core/kconfig.hhas defines to enable/disable features and other crucial configurations. -
It is a must that the number of tasks in your application matches the number defined in
RK_CONF_N_USRTASKS, as well as the lowest effective priority task number (the highest number) matches what is defined inRK_CONF_MIN_PRIO(maximum priority is 31). -
If you are using application timers, the stack size of the system task that runs the callouts might need to be adjusted on
RK_CONF_TIMHANDLER_STACKSIZE- remember this value is in WORDs (a word has 4 bytes). If you are including any hook on the IdleTask, also adjustRK_CONF_IDLE_STACKSIZE. These values must be a multiple of 8, and that is a general rule for stack sizes. -
To declare the objects needed for a task you can use the convenience macro
RK_DECLARE_TASK()- checkkapi.hfor more information. Importantly convenience macros that start withRK_do not need a trailing;at its end, because they are not supposed to be seen as functions (some do not even take arguments). Macros that start with aK_are function-like macros.
-
Sections explaining QEMU building system and its integration to VSCode on macOS, Windows and Linux are available on the Wiki links.
-
A comprehensive Docbook explains kernel mechanisms (including the design rationale) and usage examples.
-
Complete application code for QEMU (on this repo) and Nucleo boards (on a wiki page) and are useful for understanding how to structure your code.
Copyright (C) 2025 Antonio Giacomelli | www.kernel0.org