Specifying offset in PolyORB-HI-C and AADL models

Jump to: navigation, search

For periodic threads, it would be useful to wait a given amount of time after activation, prior to functional code execution. This is called the offset : a certain amount of time that is required to wait before executing any functional code.

Specifying the offset for threads

The offset on each thread is specified using the Dispatch_Offset AADL standard property. It is a time value that is later used either for code generation (see below) or scheduling analysis (please read Cheddar-related materials). The following AADL model provides an example of the use of this property. In the following, the task has a period of 2000ms and a dispatch offset of 500ms.

thread implementation P.Impl
Mycalls: {
  P_Spg : subprogram Do_Ping_Spg;
  parameter P_Spg.Data_Source -> Data_Source;
  Recover_Entrypoint_Source_Text     => "recover";
  Dispatch_Protocol                  => Periodic;
  Period                             => 2000 Ms;
  Deadline                           => 2000 ms;
  Priority                           => 2;
  Dispatch_Offset                    => 500 Ms;
end P.Impl;

Translation in the generated code

In the generated code, this AADL property is mapped in activity.c with the following new artifacts :

  • An offset variable in the thread function.
  • A function call to store the appropriate time representation in the offset variable
  • A call to __po_hi_task_wait_offset to wait the offset each time the task is activated.
void worker_function ()
  __po_hi_time_t offset;
  __po_hi_milliseconds (&(offset), 500);
  __po_hi_wait_initialization ();
  __po_hi_compute_next_period (...);
  while (1)
    __po_hi_wait_offset (&offset);
    /* call to functional code and wait next period */
    __po_hi_compute_next_period (...);

PolyORB-HI-C services for Offset Management

In PolyORB-HI-C the function __po_hi_task_wait_offset is done to wait a given amount of time passed as parameter. The function definition can be found in include/po_hi_task.h header file, which is the following :

void __po_hi_task_wait_offset (const __po_hi_time_t* time);