SyncCharts in C

SyncCharts in C (SC) are a light-weight mechanism to express reactive control flow in C programs.

SC combines the formal soundness of SyncCharts, including deterministic concurrency and preemption, with the efficiency and wide support for the C language. To write and execute an SC application requires neither specific tools nor special execution platforms, although both may support this concept further. All that is needed to get started is an understanding of SyncCharts (see eg the tutorial provided by André [2003]) and of their implementation in SC as described by von Hanxleden [2009], the SC files available here and a C compiler. To develop an SC application, one has to write some <application>.c that mainly defines a tick function that controls state behavior. The tick function consists of regular C code combined with SC operators, defined as C functions/macros.

The main idea of SC is to emulate multi-threading, inspired by reactive processing. As we do not have direct access to the program counter at the C language level, we keep track of individual threads via state labels. Precedence among transitions, respecting strong/weak abortions and hierarchy, and the adherence to signal dependencies is achieved by checking transition triggers in the proper order as well as assigning appropriate thread ids and priorities.

SC's conciseness, completeness and semantic closeness to SyncCharts make it an attractive candidate for a number of scenarios:

  1. As a regular programming language, requiring just a C compiler, no special tools or hardware;
  2. As an intermediate target language for synthesizing graphical SyncChart models into executable code, in a more traceable manner than the traditional path through Esterel;
  3. As instruction set architecture for programming precision timed (PRET) or reactive architectures; or
  4. As a virtual machine instruction set.

Download

The SC code is open source under a "two-clause BSD license" (see license) and is free for all uses. The current release can be downloaded here (version information). The whole tar ball, including examples, is about 20 KBytes. Yes, we do mean light-weight!

The release includes:

Links

References