Well-formed control flow for critical sections in RTFM-core

The mainstream of embedded software development as of today is dominated by C programming. To aid the development, hardware abstractions, libraries, kernels and lightweight operating systems are commonplace. Such kernels and operating systems typically impose a thread based abstraction to concurrency. However, in general thread based programming is hard, plagued by race conditions and dead-locks. For this paper we take an alternative outset in terms of a language abstraction, RTFM-core, where the system is modelled directly in terms of tasks and resources. In compliance to the Stack Resource Policy (SRP) model, the language enforces (well-formed) LIFO nesting of claimed resources, thus SRP based analysis and scheduling can be readily applied. For the execution onto bare-metal single core architectures, the rtfm-core compiler performs SRP analysis on the model and render an executable that is deadlock free and (through RTFM-kernel primitives) exploits the underlying interrupt hardware for efficient scheduling. The RTFM-core language embeds C-code and links to C-object files and libraries, and is thus applicable to the mainstream of embedded development. However, while the language enforces well-formed resource management, control flow in the embedded C-code may violate the LIFO nesting requirement. In this paper we address this issue by lifting a subset of C into the RTFM-core language allowing arbitrary control flow at the model level. In this way well-formed LIFO nesting can be enforced, and models ensured to be correct by construction. We demonstrate the feasibility by means of a prototype implementation in the rtfm-core compiler. Additionally, we develop a set of running examples and show in detail how control flow is handled at compile time and during run-time execution.

[1]  Theodore P. Baker,et al.  A stack-based resource allocation policy for realtime processes , 1990, [1990] Proceedings 11th Real-Time Systems Symposium.

[2]  Adam Dunkels,et al.  Contiki - a lightweight and flexible operating system for tiny networked sensors , 2004, 29th Annual IEEE International Conference on Local Computer Networks.

[3]  Per Lindgren,et al.  RTFM-core: Language and implementation , 2015, 2015 IEEE 10th Conference on Industrial Electronics and Applications (ICIEA).

[4]  Narain H. Gehani,et al.  Concurrent C , 1986, Softw. Pract. Exp..

[5]  Marcus Lindner,et al.  RTFM-lang Static Semantics for Systems with Mixed Criticality , 2014 .

[6]  Per Lindgren,et al.  Real-time for the masses, step 1: Programming API and static priority SRP kernel primitives , 2013, 2013 8th IEEE International Symposium on Industrial Embedded Systems (SIES).

[7]  Narain H. Gehani,et al.  Implementing concurrent C , 1992, Softw. Pract. Exp..

[8]  Edward A. Lee The problem with threads , 2006, Computer.

[9]  Per Lindgren,et al.  RTFM-core: Course in Compiler Construction , 2014, WESE.