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

Ths thesis can be done either as a Bachelor's thesis or Master's thesis, and shall add specialized system calls to the Zephyr RTOS.

For the Master's thesis, 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.

For a bachelor's thesis, manually minimized system call functions shall be integrated into the Zephyr compilation process. The call-site must be rewritten to call this optimized function, for example precalculated scheduler datastructure modifications. This allows to see the potential of automatic specialization per application. 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]
RTAS Conference A
ARA: Static Initialization of Dynamically-Created System Objects
Björn Fiedler, Gerion Entrup, Christian Dietrich, Daniel LohmannProceedings of the 27th IEEE Real-Time and Embedded Technology and Applications Symposium (RTAS'21)2021.
PDF Details Video Teaser Video 10.1109/RTAS52030.2021.00039 [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]

Controlling the Kite: Static Control-Flow System Analysis for Embedded Controllers with Zephyr RTOS in ARA

The ARA toolchain shall support the system-state enumeration for Zephyr-based embedded applications.

 
Typ
Masterarbeit

 
Status
abgeschlossen

 
Supervisors
Andreas Kässens
Gerion Entrup
Daniel Lohmann

 
Project
AHA

 
Bearbeiter
Vitali Fendel (abgegeben: 03. Dec 2024)

RTOS of the Day: Performance Comparison and Analysis of Open Source Real-Time Operating Systems

For optimization of RTOS, we need a performance measurement baseline. RTOS-specific benchmarks like ThreadMetric can provide numbers on how some implementations are more or less suitable for time-critical applications.

 
Typ
Bachelorarbeit

 
Status
abgeschlossen

 
Supervisors
Andreas Kässens
Daniel Lohmann

 
Project
AHA

 
Bearbeiter
Jan Heinemeyer (abgegeben: 14. Feb 2025)