SuperTinyKernel RTOS (STK) is a lightweight, high-performance, deterministic real-time operating system (RTOS) for resource-constrained embedded systems. It is implemented in C++ with a clean object-oriented design and released under the MIT License. Unlike many traditional RTOSes, STK concentrates solely on a preemptive, deterministic thread scheduler rather than providing peripheral abstraction, minimizing kernel size while prioritising timing accuracy and predictability. STK imposes no dynamic memory allocation, has no dependency on the C++ Standard Library for templates, and provides a fully-featured C interface, making it suitable for safety-critical development. The absence of heap allocation satisfies MISRA C++:2008 Rule 18-4-1. STK avoids aggressive namespace usage, does not rely on modern C++ language features, and aims for a transparent, readable implementation throughout.
Scheduling STK operates in two fundamental modes. In soft real-time mode, tasks cooperate by voluntarily yielding execution time, with the kernel applying preemptive scheduling to prevent any task from starving others. In hard real-time (HRT) mode, tasks are periodic with guaranteed execution windows and strict deadlines enforced by the kernel; any deadline violation triggers a deterministic failure callback. Tasks may follow either a static model, in which all tasks are created once at startup, or a dynamic model, in which tasks may be created and exit at runtime.
Tick and tickless modes STK supports two timer models for context switching. In the default tick-based mode a hardware timer fires at a fixed frequency and the scheduler is evaluated on every interrupt, providing simple and predictable behaviour suited to systems where timing granularity is fixed and power consumption is not a primary concern. In tickless mode, kernel suppresses the periodic interrupt and instead programs the hardware timer dynamically so that the next interrupt fires precisely at the nearest upcoming event, such as a task wakeup or deadline. This keeps the CPU in its sleep state for as long as possible, substantially reducing power draw in battery-powered or infrequently active systems while preserving full timing correctness. In STK, tickless mode allows the embedded system to achieve ultra-low power (ULP) scheduling.
Scheduling strategies STK supports all major scheduling strategies, including round-robin scheduling (RR), smooth weighted round robin (SWRR), fixed-priority round-robin (FPRR), rate-monotonic scheduling (RM), deadline-monotonic scheduling (DM), and earliest deadline first scheduling (EDF). The EDF implementation selects the runnable task with the smallest remaining deadline and is provably optimal for single-processor systems. Both RM and DM implementations include worst-case response time (WCRT) schedulability analysis. Custom scheduling strategies can be provided by implementing a dedicated C++ interface. STK also provides two proprietary Mixed criticality scheduling strategies available under a commercial license. The two-level Mixed-Criticality Adaptive Scheduler (MCAS) partitions tasks into low- and high-criticality groups, distributes CPU time between them at a configurable ratio using a token-bucket mechanism, and automatically suspends low-criticality tasks when a high-criticality task overruns its execution budget, resuming normal operation after a configurable cooldown period. The four-level variant (MCAS4) generalises this model to four independent criticality levels with cascade escalation and recovery, and adds an elastic CPU share adaptation mechanism driven by a per-group exponential moving average (EMA), also termed an exponentially weighted moving average (EWMA), execution-pressure estimator, allowing groups under sustained load to borrow CPU share from lower-criticality neighbours without altering worst-case response time guarantees.
Synchronization STK provides a rich synchronization API comprising mutexes (including a recursive variant and a reader-writer variant with a writer-preference policy to prevent writer starvation), counting semaphores with a direct-handover signalling policy, condition variables, binary event objects supporting manual-reset and auto-reset modes, 32-bit event flag groups allowing tasks to wait on any one or all of a set of flags, critical sections, spinlocks, a thread-safe typed FIFO pipe, and a fixed-capacity message queue suitable for heterogeneous payloads. Custom synchronization objects can be integrated directly with the kernel scheduler. Synchronization support is optional and can be omitted at compile time, causing the compiler to strip all related code and reduce flash and random-access memory (RAM) consumption.
Memory STK includes a deterministic, fragmentation-free memory allocation module designed for systems where dynamic heap allocation is undesirable or prohibited by coding standards such as MISRA C++. It provides a fixed-size block allocator that manages a pool using an intrusive free-list structure, yielding O(1) allocation and deallocation with a minimal critical section and zero fragmentation over any run duration.
Thread-local storage STK provides per-task thread-local storage (TLS) through a dedicated CPU register. This allows each task to maintain private state without any locking or dynamic allocation, with no runtime overhead beyond a register read or write.
Task privilege separation On ARM Cortex-M cores implementing the memory protection unit (MPU) – Cortex-M3 and newer – STK supports hardware-enforced privilege separation between tasks. Trusted driver tasks run in privileged thread mode with full peripheral access, while application or untrusted tasks run in unprivileged mode where any direct peripheral register access triggers a hardware fault. This isolates potentially attacker-controlled code paths, such as tasks that parse network, USB, or firmware-update payloads, from safety-critical hardware state. All kernel services remain accessible to unprivileged tasks.
… excerpt ends here. Continue reading the full article.

