IBM
Contents Index Previous Next



Overview of Important Data Structures


All the important types discussed in this section are defined in extreme_kern.h. Please have that file ready at hand while reading this section.

In generated code there is information about each part in the system. For each part a struct variable of type xPartTable is generated. Example:

xPartTable xPartData_p_01 = {
  (xInstanceData *)xInstData_p_01,
  sizeof(yVDef_p_01),
  1,
  1,
  (xIniFunc)yIni_p_01,
  (xTransFunc)yPAD_p_01,
  xTransitionData_p_01,
  xStateIndexData_p_01
#ifdef CFG_USED_GUARD
  , 0
#endif
}; 

There is also in generated code an array containing the addresses to the xPartTable structs for all parts in the system. This global variable is used at many places to access information about parts. Example:

xPartTable *xPartData[] = {
  &xPartData_p_01,
  &xPartData_q_02
};

Looking through the contents of the xPartTable struct, it contains the following components:
Component Description

InstanceData

A pointer to an array with one element for each instance of the part. These components are used to store instance specific values of different kinds, like state and local variable values.

DataLength

The size of each array element mentioned for the previous component.

MaxInstances

The maximum number of concurrent instances of this part.

InitialInstances

The number of instances at system start up.

yIni_Function

A reference to a function that initializes the at-tributes of the active class.

yPAD_Function

A reference to the function that implements the state machine for the part.

TransitionTable

and StateIndexTable

Tables (arrays) used to determine how to handle a certain signal in a certain state.

GuardFunc

A reference to a function that can compute guard expressions used in the state machine.

ThreadNumber

The thread that this part belongs to. Only used in threaded integrations.

Other important global data structures are the array of available signals and timers. These are

/* Signal array */
static xSignal
    xSignalArray[CFG_STATIC_SIGNAL_INSTS];

/* Pointer to first element in list
   of free signals */
static xSignal *xFreeSignalList;

/* Timer array */
static xTimer
    xTimerArray[CFG_STATIC_TIMER_INSTS];

/* Pointer to first element in list
   of free timers */
static xTimer *xFreeTimerList;

These variables can be found in extreme_kern.c and define one array of signals and array of timers, together with starting pointers for the lists of available signals and timers.

The last important global data structure is the xSystemData variable called xSysD. In a non-threaded application xSysD is a variable of type xSystemData, while in a threaded application xSysD is an array with components of type xSystemData, with one component per thread.

xSysD contains global information about what is going on just now in the application or thread. The following components can be found in xSysD:
Component Description

CurrentPid

This is the Pid value for the currently executing instance in the application or thread.

CurrentSymbolNr

This is the symbol number where the execution should start in the function implementing the state machine. The selection is performed by a switch in the beginning of the function.

CurrentData

This is a pointer to the local variables for the ex-ecuting instance. This reference goes to the ap-propriate element in the InstanceData compo-nent in the xPartTable for the part.

CurrentSignal

This is a pointer to the signal that caused the cur-rently execution transition.

SignalQueue

This is a reference to the first signal in the global signal queue (global for application or thread). The signals in this queue are linked together in a linked list.

ExternSignalQueue

This is a signal queue where signals coming from other threads or from the environment first are stored. At well defined points (between transi-tions) signals are moved to the SignalQueue.

OutputSignal

Variable used as temporary variable while sending a signal in generated code.

TimerQueue

This is a reference to the first timer in the global timer queue (global for application or thread).

ThreadVars

In a threaded application this is a struct containing data about the thread itself. The contents depend on the integration.

Some other data structures that are worth discussing in more detail are Pid values, and contents of signals and timers.

A Pid value is a reference to an executing instance. The Pid value consists of two parts, the part number (parts are numbered 0, 1..., which is used to index the global xPartData array) and the instance number (which is used to index the InstanceData array in the xPartTable for the part). The Pid type is an unsigned type of suitable size to contain these two values.

A signal is defined by the type xSignal and contains the following components.
Component Description

Next

Pointer used to link signals in lists.

Sid

The identity of the signal (signal type)

Receiver

The Pid value of the receiver.

Sender

The Pid value of the sender.

SaveState

Used to speed up handling of saved signals.

Prio

The signal priority, if you have set up to use signal priorities.

ParPtr

A pointer to the parameters of the signal. Refers either to ParArea or to allocated memory.

ParArea

This is the inline area for signal parameters used if the parameters fit into this area.

A timer is defined by the type xTimer and contains the following components:
Component Description

Next

Pointer used to link timers in lists.

Sid

The identity of the timer (timer type)

Owner

Pid value for the owner of the timer

Time

The time set for the timer.

TimerParValue

Optional integer parameter for timers.


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