IBM
Contents Index Previous Next



Implementation


In this section the implementation details are discussed. These details are meaningful for understanding how a generated Cmicro application does work.

Time

For host simulation, with the predefined integration settings, a time unit represents one second. In target applications, time is to be implemented by the user (see subsection Defining the SDL System Time Functions in mk_stim.c).

Real Time

If real time is used, then there will be a connection between the clock in the executing program and the wall clock. For applications the user must provide the connection with the wall clock, normally the hardware timer.

Note:

The C standard function time used as the real time clock returns the time in seconds. The implementation of the clock can be changed by re-implementing the function xmk_NOW in mk_stim.c.

Scheduling

The Cmicro Kernel does not use a process ready queue. It processes the signals in the order of their appearance. To do this, there is a signal queue which stores the signals sent to any process (either internally or externally). There are different ways to influence the scheduling when using the Cmicro SDL to C Compiler:

Assigning Priorities to Processes - Preemptive Scheduling

It is possible to assign priorities to process types (using SDL'88 terminology). The processes' priorities are assigned when designing the SDL system. They are assigned using the #PRIO directive.

There are some things to be kept in mind when using process priorities:

The Cmicro Kernel handles process priorities by collecting all signals sent to processes of the same priority in a separate queue. Thus, there is a queue for each priority level.

While the SDL system is running the kernel checks for signals in the queues with decreasing priority. This check takes place whenever an SDL output appears or a process performs an SDL nextstate operation. Because of the kernel checking for signals whenever an output takes place, it is possible to have preemptive scheduling.

Assume, there are two process types lowprio and highprio. Let process type lowprio have the priority one and process type highprio have the priority zero.

If an instance of process type lowprio performs an output to process type highprio, there appears a signal in a queue of a higher priority level (zero is the highest priority level available, process lowprio has priority one) which leads to the kernel immediately working on the signal sent to the process highprio. The transition of process lowprio will not end until process highprio has finished its transition invoked by the signal.

This way of scheduling is implemented using recursion.

Note:

Process priorities are available only when using a compiler which can handle recursion.

There is basically no restriction on the number of priority levels, but the target and compiler used will of course limit the depth of recursion.

As a general recommendation process priorities should not be assigned one per process type, but the process types should be grouped according to their purposes and these groups should then be assigned a priority level.

Assigning Priorities to Signals

The signals in the queue(s) are normally ordered according to their appearance (FIFO-strategy). By assigning priorities to signals this ordering is user definable. The directive #PRIO is used to assign a priority to signals.

Priority increases with decreasing numbers, but there is no restriction to use consecutive numbering.

Whenever a signal is sent, it is inserted into the signal queue(s) according to its priority.

Assume, there is a process performing two signal outputs, first_sig and second_sig. Using the standard FIFO-strategy signal first_sig would be worked on before signal second_sig. But with signal priorities and signal first_sig assigned priority fifty and signal second_sig assigned priority twenty, signal second_sig would be in front of signal first_sig in the queue and thus would be worked on before signal first_sig.

For more details please refer to Assigning Priorities - Directive #PRIO.

Combinations of Signal/Process Priority

Every combination of signal and process priorities may be used. In this way it is possible to adapt the scheduling to the users' needs.

Note:

Without process priorities a transition once started will have to be finished before the next transition can be dealt with. This is valid regardless of the time it will need to finish a transition.

Synonyms

External Synonyms

External synonyms can be used to parameterize an SDL system and thereby also a generated program. The values that should be used for the external synonyms must be included as macro definitions into the generated code, for instance by including another header file.

Using a Macro Definition

To use a macro definition in C to specify the value of an external synonym, the user should perform the following steps:

  1. Write the actual macro definitions on a file.

Example 575 : Macro Definition

#define synonym1 value1
#define synonym2 value2

The synonym names are the SDL names (without any prefixes).
  1. Introduce the following #CODE directive at the system level among the SDL definitions of synonyms, sorts, and signals, for example, but before any use of the synonyms.

Example 576 : #CODE Directive

/*#CODE
#TYPE
#include "filename"
*/

If this structure is used, the value of an external synonym can be changed merely by changing the corresponding macro definition and re-compiling the system.

Procedure Calls and Operator Calls

In SDL-92, value returning procedures and operator calls are introduced. This means, that an SDL procedure can be called within an expression. As the Cmicro SDL to C Compiler cannot handle procedures with states, it is not necessary to map such calls to a different scheme.

Example 577 : Procedure Call

TASK i := (call p(1)) + (call Q(i,k));

is translated to something like:
i = p(1) + Q(i,k);

Note:

The value returning procedure calls are transformed to C functions which return values.

Operators which are defined using operator diagrams, are as in the models in the SDL recommendation, treated exactly as value returning procedures.

Generation of PAD function

The code generation for the PAD function is different compared with Cadvanced, in the way that code that is common in process types is copied into the PAD function for instantiated processes. This is implemented in contrast to Cadvanced, where for each process type definition there is a C function generated once, that is called by the instantiated PAD function, for common code. This makes a difference when system partitioning and/or file separation is used.

Any

`Any' should not be used in applications using the Cmicro SDL to C Compiler, as it leads to an error message.

Calculation of Receiver in Outputs

The Cmicro SDL to C Compiler is a code generator using the semantics of SDL-92 with some restrictions. The behavior for output is according to the rules described in the following:


http://www.ibm.com/rational
Contents Index Previous Next