IBM
Contents Index Previous Next



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:

  1. /* In the user's initialization task do : */
    
    Initialize memory
    
    Initialize time
    
    Initialize mailbox(es) or message queue(s)
    
    Initialize other resources
    
    Make the SDLTask an operating system task
    
    Wait until the SDLTask has finished initialization
    
    Continue with creating other operating system tasks
    
    
    

The model for what the SDL task does in a light integration can be sketched with something like:

  1. Initialize SDL Target Tester
    
    Initialize Cmicro SDL queue
    
    Initialize Cmicro Trace options (if wanted)
    
    Initialize SDL and execute start transitions of the 
    process instances which are to be created statically
    
    
    
    Forever 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 the
    
        timer that will expire next
    
    
    
        if there is at least one active timer
    
        {
    
          listen on the operating system queue for the
    
          remaining duration, by using a blocking
    
          function call
    
        }
    
        else
    
        {
    
          listen forever to the operating system queue
    
          by using a blocking function call
    
        }
    
        If a message was received, format the message
    
        and send it as an SDL signal to the SDL system
    
      }
    
      If a timeout occured (remaining duration),
    
      then check all the timers. For each timer that
    
      has been expired there will be one signal
    
      put into the SDL queue
    
      
    
      process 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:

  1. Create the module with the C main() function.

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:

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.

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.

  1. Define the macros which are needed in the task function.

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.

  1. Initialize the environment.

This is usually done in xInitEnv(), but probably outside SDL, depending on the needs of the user.

  1. Adaptions for sending signals from the SDL task to any other OS task.

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.

Note:

All necessary resources, e.g. the receivers queue, must have been created before they are used.

  1. Adaptions for receiving signals from any other OS task and translation of the signal parameters.

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.

Note:

All necessary resources must have been created before they are used.

  1. Implement timers in SDL.

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.

  1. System shutdown.

There is no default way to shutdown, but usually it is enough to implement the xCloseEnv function and call it at an appropriate place.

  1. Cmicro Target Tester

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.

Note:

The Target Tester can only used for tracing.

  1. Compile and link

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.

  1. Save the settings and press Full Make.

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