Project

General

Profile

Task declaration

Tasks define an execution context suitable for running the codels of activities).

(20) task ::=

"task" identifier opt-properties ";"

(124) opt-properties ::=

[ "{" properties "}" ]

(125) properties ::=

{ property }

(126) property ::=

component-property
| interface-property
| task-property
| service-property
| codel-property
| throw-property

A task may optionally define a state machine with codels. In this case, the state machine runs in the background as soon as the component starts, independently of any external service request. The state machine always starts in the start state. If a codel yields to the ether state, the state machine stops. When the component is shutdown, the stop codel (if it exists) is always invoked.

In any case, the task is always available for processing external service requests, no matter if it has its own state machine or not.

(35) fsm-codel ::=

"<" event-list ">" identifier "(" codel-parameters ")" "yields" event-list

The task declaration also defines a few properties like a priority and a stack size. They are not necessarily used by all templates, but this allows to target real-time embedded systems.

(21) task-property ::=

( "period" const-expr time-unit
| "delay" const-expr time-unit
| "priority" positive-int-const
| "scheduling" "real-time"
| "stack" positive-int-const size-unit ) ";"

period

The granularity of the codel scheduler. Periodic task will sequence the codels they manage at that frequency. If unspecified, the task has no period and sequences the codels as fast as possible.

delay

The initial delay before starting the scheduler. This can be used to delay two tasks running at the same period in the same component.

priority

Can be used to prioritize different tasks whithin the same component. Priorites are expressed as a integer between 0 and 255 (0 beeing the highest priority and 255 the lowest). This may not be supported by all templates.

scheduling real-time

This indicates that the task requires real-time scheduling. This may not be supported by all templates.

stack

Defines the required stack size for this task (in bytes if no unit is given). The stack size should be big enough to run all codels that the task manages. The property can also be specified for all tasks, including implicit tasks defined by a template, at the component level. This may not be used by all templates.

Example

The following declaration declares a task with an initialization codel running only once when the task starts:

component foo {
  task t {
    codel <start> init_codel() yield ether;
  };
};

The following declare a periodic task, running some code in the background:

component foo {
  ids { long data };

  task t {
    priority 100;
    stack 64k;
    period 50ms;

    codel <start> do_init(out data) yield compute;
    codel <compute> do_compute(inout data) yield compute, stop;
    codel <stop> do_cleanup(in data) yield ether;
  };
};