SystemJ in a Nutshell

So, what SystemJ is? It is a language built on top of Java programming language, where Java can be considered its subset. The basic programming unit is a SystemJ program, or in the language called system. We will interchangeably use program and system although the word system is a reserved keyword of the language itself.  A typical SystemJ program consists of multiple asynchronous concurrent entities on the top level of program specification. Those entities, called clock domains, execute concurrently and asynchronously (each at its own logical speed) and sometimes communicate each with the other using message passing. Communication mechanism in system is an object called channel.

Each clock domain in SystemJ can contain a number of synchronized concurrent behaviors called reactions. Reactions within a clock domain execute synchronously driven by an internal logical clock, which is in SystemJ called a tick. In each tick each reaction makes one step of its execution and waits until all reactions within the clock domain have done the same. We say the reactions execute in lock-step. Each reaction can be further decomposed into a number of reactions, effectively creating parent-child hierarchy, and the number of these levels is theoretically unlimited. The only thing to remember is that all reactions (parents and children) within a clock domain are synchronized. Also, as reactions are concurrent, they need to communicate each to the other. The mechanism for communication between reactions within a clock domain is another object called a signal. Signals have an interesting property. If a reaction emits a signal, it is immediately, in the same tick, visible to all other reactions in a clock domain. We say, the signals are broadcasted. If a reaction in a clock domain needs to communicate with a reaction in another clock domain, it uses channels. Channel, opposite to signal, is used for point-to-point communication. Reactions that communicate over a channel are called sending and receiving reaction. A reaction which does not have children is referred to as a simple reaction. Simple reaction is nothing but what usually programmers consider a sequential program. In SystemJ simple reaction is described using only sequential statements. There are two kinds of these statements: (1) new statements of the SystemJ language that belong to the flow control and communication mechanisms and (2) all statements of Java language. If a programmer is not using SystemJ control constructs, then a simple reaction is effectively a Java program. Reactions which have children also use sequential statements, both from SystemJ and Java repertoire, but they also use parallel statements by which they can create and spawn their children.

A graphical illustration of a SystemJ program given in the figure reflects the structure (hierarchy and connections) between the parts of the program, which is actually a software system. The program has three top level asynchronous behaviors, clock domains, called CD1, CD2 and CD3. Clock domain CD1 has two synchronous parallel reactions R11 and R12, clock domain CD2 has a single reaction R21 and clock domain CD3 has two high-level reactions R31 and R32, while R32 also has two children reactions, R321 and R322. The notation for reactions follows this parent-child relationship, which can also be presented as a hierarchical tree shown on lower part of the figure.


The figure also gives an informal graphical notation for GALS model of computation that all SystemJ programs comply with. On the top level are clock domains and then they may be decomposed into further concurrent behaviors, reactions. We also see that clock domain CD1 communicates with clock domain CD2 using channel C12, clock domains CD1 and CD3 do not communicate directly at all, and clock domains CD2 and CD3 communicate via channels C23 and C32, respectively. Arrows show the direction of communication. Also, the figure graphically shows which reactions within clock domains communicate each with the other through signals. You have to notice that signals are emitted and broadcasted from a reaction and then become visible to all reactions. Arrows in the figure show communication between reactions via signals actually indicate which reaction(s) use the emitted signals. For example, reaction R11 emits signal E, which is used in reaction R12. Conversely, reaction R12 emits signal F, which is used to control computation in reaction R11.

In figure, we have graphically presented the environment to SystemJ program with which program exchanges information and that way becomes a system as it gets inputs and outputs. SystemJ program allows communication with the environment only through special kind of signals, called input and output signals. Those are signals used by reactions, but only for communication with the environment. It is also important to note that environment is very abstract for SystemJ programs. It can be physical environment with which SystemJ program interacts thorough electronic signals, it can be communication line through which messages are exchanged between the program and the environment or can be another program written in Java or any other programming language, which “understands” the signal abstraction.

Finally, the figure illustrates the place of Java code. Java statements are freely interleaved with SystemJ statements to make complex computations and wrap them up into complex control mechanisms through which reaction communicate each with the other and external environment. Java code is used to implement usual programming techniques and abstractions of variables, data types and objects which are not provided by SystemJ itself.

So, what is SystemJ, then? It is the language that enables structuring of software system as one in the figure and provides all run-time requirements to execute such a system correctly. For Java programmers that means SystemJ program will be translated into Java code, which is then compiled by Java compiler to provide the code that executes on usual Java Virtual Machine(s). Once we know this, we can delve one step deeper into SystemJ and describe the major elements of its syntax and semantics. As SystemJ basic language is textual language with its own Java-like syntax, we will first introduce the basic features of the language. For more detailed description of SystemJ visit SystemJ Entities and Objects and SystemJ Kernel Statements and Syntax. To see how a program from the figure looks in SystemJ visit SystemJ in Action – an Example Program. More details on how to write simple and complex concurrent programs in SystemJ read the SystemJ Manual.