![]() |
![]() |
![]() |
![]() |
![]() |
Light Integration
A light integration is to be performed if the SDL system including the Cmicro Library should execute within just one operating system task.
The SDL system usually communicates with the environment by using a mailbox or message queue or something similar, which is provided from the operating system. Within the SDL system, the Cmicro scheduler is used. This means that signals that are sent internally in the SDL system are not sent via the mailbox/message queue from the operating system.
Model
The execution model for an SDL system in a light integration can be sketched with the following meta code:
/* In the user's initialization task do : */Initialize memoryInitialize timeInitialize mailbox(es) or message queue(s)Initialize other resourcesMake the SDLTask an operating system taskWait until the SDLTask has finished initializationContinue with creating other operating system tasksThe model for what the SDL task does in a light integration can be sketched with something like:
Initialize SDL Target TesterInitialize Cmicro SDL queueInitialize Cmicro Trace options (if wanted)Initialize SDL and execute start transitions of the process instances which are to be created staticallyForever do{if there is a signal to be consumed{Get the next message from the OS queue,without suspending the SDL Task}else, if there are only saved signals{evaluate the remaining duration for thetimer that will expire nextif there is at least one active timer{listen on the operating system queue for theremaining duration, by using a blockingfunction call}else{listen forever to the operating system queueby using a blocking function call}If a message was received, format the messageand send it as an SDL signal to the SDL system}If a timeout occured (remaining duration),then check all the timers. For each timer thathas been expired there will be one signalput into the SDL queueprocess SDL signal}Procedure to Implement the Model
This subsection gives the user the details that he must know for the implementation of the given model. He has to deal with some special macros which must be defined and used. Their names have the prefix XLI_.
The user must execute the following steps:
This module has to contain the C main() function, corresponding to the first meta code in the section before. The module should include ml_typ.h and the interface file (e.g component.ifc). In this module the definitions of other external tasks can take place. The main function should handle the following steps:
- initialize the memory if required
- initialize the hardware timer
- initialize OS resources (semaphore, message queues,...)
- start the necessary OS tasks, this means also to start the task which represents the SDL state machine.
- wait until all tasks are started
- Set XLI_LIGHT_INTEGRATION
To set this flag the Targeting Expert can be used. Choose your integration and choose "Support light integration" below Target Library and kernel tab. When the box is chosen three things will happen.
- the compiler flag XLI_LIGHT_INTEGRATION will be set
- the compiler flag XMK_USE_INTERNAL_QUEUE_HANDLING is automatically set
- The macro XLI_INCLUDE is set with the name in the edit line (default is 'li_os_def.h')
This header file is included in ml_typ.h and must contain a definition of XLI_SDL_TASK_FUNCTION. With the help of this macro, the main function known from the standard Cmicro kernel will be mapped to the OS task function. The body of this function is located in mk_user.c.
The task function is corresponding to the second meta code of the model. The following macros can be defined in the header file:
If temporary variables are needed in the task function, they can be declared at this place. It is inserted at the top of the task function.
If temporary variables for the communication resources are needed, they can be defined within this macro. It is expanded at the top of the function which queries the queue.
Any preparations in the task function can be done with this. It follows XLI_TEMP_TASK_VARS at the start of the task function.
Here the communication resources for the OS task can be created (which ones that will be used depends on the user and the used OS). In the further part of the document the term queue will be used instead of communication resources.
If a synchronization between the OS tasks is needed, this should be defined with XLI_START_OS_TASK_SYNC.
The function xmk_RunSDL() represents the continuous repeating part of the meta model. Inside of it xmk_QueryOSQueue() is called and it is responsible for the query of the OS queue. If the SDL queue contains signals, XLI_GET_NEXT_MESSAGE_FROM_OS_QUEUE is used to read nonblocking from the OS queue. The task function should not be suspended.
If the SDL queue is empty, but at least one timer is active, XLI_LISTEN_ON_OS_QUEUE_WITH_TIMEOUT(TIMEOUT) is used to read from the OS queue with a time-out. The OS queue should be queried as long as the next timer expire. The duration is given with the parameter TIMEOUT.
If there is no signal in the SDL queue and there is no timer active XLI_LISTEN_ON_OS_QUEUE_NO_TIMEOUT is used to query the OS queue while the next OS message arrives. The SDL task should be suspended.
The content of XLI_CALL_xInEnv is executed after an OS message arrives. It should pass on the content of the received OS message (a signal with parameter) to the SDL system. Normally xInEnv is called to send the signal to the SDL system. The user has to define a data structure which transports the signals from the OS to the SDL system. The name for the data structure can be assigned with XMK_xInEnv_PARTYPE. The name for the parameter of xInEnv can be assigned with XMK_xInEnv_PARNAME.
This can be defined with something that sign up the other non-SDL tasks about ending of the SDL task.
This is usually done in xInitEnv(), but probably outside SDL, depending on the needs of the user.
Usually, users must fill out the function xOutEnv() for sending signals to the environment (another operating system task). It is up to the user what kind of communication is to be used in this direction.
All necessary resources, e.g. the receivers queue, must have been created before they are used.
In the SDL task, it is necessary to format the incoming parameters after the message was read from the message queue. Afterwards the signal can be sent to the SDL system with XMK_SEND_ENV.
All necessary resources must have been created before they are used.
It should be possible to implement hardware timers, like it is described in Defining the SDL System Time Functions in mk_stim.c. A usual way is to increment a global variable (of type xmk_T_TIME) by using an operating system task or similar. A time overrun is automatically detected by the Cmicro Kernel.
There is no default way to shutdown, but usually it is enough to implement the xCloseEnv function and call it at an appropriate place.
The next thing that is remaining is the SDL Target Tester. The instructions which have been given for bare integration, are still valid. The easiest way to use the SDL Target Tester in a light integration is to dedicate a communication interface exclusively for the SDL Target Tester.
The added files must be registered as source files in the Targeting Expert. Please view Source Files to get information on how to add more files to the list of files to be compiled. The Targeting Expert will automatically add these files to the makefile.
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |