Software for Embedded Systems: Serializing Compilers and Its  Applications

by Andre Costi Nacul

In order to cope with the complexity of systems, engineers are  turning to software. In part, well established programming models,  highly evolved tool chains, ease of software reuse, availability of  open-source software, and expeditious nature of the design-compile- execute paradigm make developing a new feature in software more  favorable. It is assumed that, in coming years, more than 70% of  product features are going to be supported by software.
In particular, the concurrent programming paradigm is an ideal model  of computation for design of embedded systems, which often encompass  inherent concurrency. The support for concurrent programming is  usually provided by a real-time operating system (RTOS). Usually, an  RTOS is a generic framework which can be used across a large number  of processors and applications. An RTOS provides coarse grained  timing support, and is loosely coupled to the running tasks. As a  result, an RTOS is seldom optimized for any particular application.

Despite of all the recent enhancements to compiler technology,  current compilers have a limited understanding of tasks. Generally,  the compiler is tightly integrated with the platform. Traditional  compilers are efficient in using platform specific resources, and in  generating an optimized instruction sequence. Current compiler  technology is capable of extracting instruction-level parallelism  (ILP), to varying degrees. Traditionally, ILP comes from optimizing  loops, and most likely analyzes code at the basic block level. Today,  there is no compiler that can detect parallelism at the task level.  Parallelism detection is usually restricted to basic block  structures, or higher level constructs such as loops. Moreover,  compilers also lack support for timing constraints of real-time  applications.

In this thesis, we propose an alternative to an RTOS based on the  idea of serializing compilers. A serializing compiler is an automated  software synthesis methodology that can transform a multitasking  application into an equivalent and optimized monolithic sequential  code, to be compiled with the embedded processor’s native optimizing  compiler. The serializing compiler can analyze the tasks at compile  time and generate a fine-tuned, application specific infrastructure  to support multitasking, resulting in a more efficient executable  than one that is intended to run on top of a generic RTOS. By having  control over the application execution and context switches, the  serializing compiler enables the fine grain control of task timing  while enhancing overall performance. Our serializing compiler  technology strengthens existing compilers, making them timing and  task-aware.

The Phantom Compiler, our implementation of a serializing compiler,  provides a fully automated mechanism to synthesize a single threaded,  ANSI C/C++ program from a multithreaded C/C++ (extended with POSIX)  program. The Phantom generated code is highly tuned for the input  application. With a serializing compiler such as the Phantom  Compiler, it is possible to generate a multitasking infrastructure  that is small in size, very efficient when context-switching, and  customized for each specific application.