Porting Embedded Rapid Prototyper Run-Time Libraries : Structure of the Code : Tasks View of the Code

Tasks View of the Code

Concurrency within the languages of Rational Statemate is represented explicitly between orthogonal states (AND states), and implicitly between separate (concurrent) activities. Sometimes it is natural to implement them as different threads (tasks), but it is also possible to implement them as a single threaded program.

All the modules of the generated code are executed sequentially, as a single thread. We refer to this thread as the “main task." The code is executed cyclically, with each iteration evaluating the next step of processing. In terms of simulation, executing the code is equivalent to executing a “go-step” repeatedly, while changing the environment asynchronously. The main difference is that the clock is incremented in real time, so time-outs will happen according to the time taken to execute the code.

Note, if the simulated asynchronous time model was selected in the compilation profile, there is no difference between the generated code and the simulation, except in some specific situations (like racing).

Multi-threading is used to implement basic activities as independent processes without complying with the one-cycle-at-a-time method.

It also allows additional environment processes to be written outside the system model. These processes typically will read inputs, drive outputs or simulate the environment. Therefore, a multi-threading capability is needed only if you wish to add threads that run “concurrently” with the generated code.

Another component in the task view of the code is the asynchronous timer. The main task issues timer requests to be notified about time-outs and scheduled actions. The timer module asynchronously notifies the main task when time-out events occur.

In addition to the above there are tasks that support the communication between the generated code and analysis tools. These are graphical back animation client task, remote panel client task, trace task, input card task.

These tasks can be created and started only if corresponding elements of compilation profile are defined. See Rational Statemate documentation for more details.