RTOS as State Machine: Synthesis of Optimized Zephyr Embedded Systems with ARA

Ara optimizing a kite to fly faster

[Generated with AI]

Context

Within the AHA project, we focus on optimizing embedded systems by specialization of the OS itself. Using the Automatic Real-time Analyzer (ARA), we perform static analysis to find interactions between different tasks, resulting in a State Transition Graph (STG)1. This information can be used to calculate effects of the system calls and tailor the implementation to the specific needs of the application. With the execution of Zephyr system calls on IR level during analysis, we are able to extract information about the OS objects before and after a system call. This allows specializing the RTOS interface to a state-machine, where system calls are transitions between global OS states.

Problem

The specialization of system calls is missing completely. The optimizer needs to generate a specialized system call implementation that can be compiled automatically into the Zephyr binary. Secondly, the correct specialized function must be called by the application.

Goal

In this thesis, the generation of specialized system calls shall be applied to the Zephyr RTOS. The student shall collect the effect of (all) system calls and generate specialized functions for each instance. The call-site must be rewritten to call this specialized function.

For example, if the application calls k_sem_take(sem_a, K_FOREVER) the generic RTOS implementation will modify at least the state on sem_a, and possibly the scheduler ready-queue. These effects can be detected statically and transformed into a very simple function, for example k_sem_take_bb42(), that will have exactly the same effect. Additionally, locking operations inside the kernel may need to be copied to match the behavior of the generic implementation. In the application IR code, the associated system call-site has to be replaced with a call to this new, specialized function.

To evaluate the results, the student shall compare the kernel overhead with an unmodified Zephyr build using benchmarks, e.g. the Thread Metric benchmark suite.

Topics: Zephyr, LLVM, Python, C, Static Analysis, Optimization

References

OSPERT Workshop B
IRx: RTOS-Aware Abstract Interpretation using an LLVM-based Interpreter
Andreas Kässens, Vitali Fendel, Daniel LohmannProceedings of the 19th Annual Workshop on Operating Systems Platforms for Embedded Real-Time Applications (OSPERT '25)2025.
PDF [BibTex]
OSPERT Workshop B
Back to the Roots: Implementing the RTOS as a Specialized State Machine
Christian Dietrich, Martin Hoffmann, Daniel LohmannProceedings of the 11th Annual Workshop on Operating Systems Platforms for Embedded Real-Time Applications (OSPERT '15)2015.
PDF [BibTex]