-
Notifications
You must be signed in to change notification settings - Fork 2
Home
RK0 is designed for MCU-based control systems where deterministic behaviour is crucial. Determinism and clear semantics are core design principles.
-
It offers an O(1) preemptive priority-based scheduler. The
choose-nextalgorithm takes approximately 4 cycles on ARMv7m and 11 cycles on ARMv6M. -
The kernel mechanisms support two complementary programming paradigms:
-
Shared-memory (procedural) – tasks synchronise using 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, operating within ‘isolated’ contexts.
-
Message queues are flexible, offering blocking or non-blocking, first or last-message semantics, and, along with scheduler policy, are a natural fit for event-based design patterns (e.g., the actor model).
-
Ports utilise priority boosting/demotion for synchronous client-server patterns.
-
-
-
The Most-Recent Message Protocol is a purpose-built 1-to-many message-passing mechanism for control loops.
-
A well-proven fixed-size Memory Allocator ensures efficient memory management, avoiding fragmentation and providing predictable memory latency (O(1)).
-
Timers (delay, periodic, bounded waiting, and callout) are optimised for precision and low overhead (O(1)).
-
core/kconfig.hcontains defines to enable or disable features and other critical configurations. -
It is essential that the number of tasks in your application matches the number defined in
RK_CONF_N_USRTASKS, and the lowest effective priority task number (the highest number) aligns with what is defined inRK_CONF_MIN_PRIO(maximum priority is 31). -
If you’re 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’re including any hooks on the IdleTask, also adjustRK_CONF_IDLE_STACKSIZE. These values must be a multiple of 8, which 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_don’t need a trailing;because they’re not meant to be seen as functions (some don’t even take arguments). Macros that start with aK_are function-like macros.
-
Sections explaining the 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) are useful for understanding how to structure your code.
Copyright (C) 2025 Antonio Giacomelli | www.kernel0.org