43 THE CYCLIC TASK SPECIFICATION
Many of these attributes are valid only for a particular kind of cyclic task. Hence, it is erroneous to specify the corresponding aspect if the attribute is not valid for that kind of task. Furthermore, the run-time raises Tasking_Error for any attribute operation not valid for the target task.
Release of the first cycle for all tasks will not occur before the system defined property Cyclic_Execution_Start_Time. This time provides a common start time for all tasks, allowing cyclic tasks to complete their initialisation before the system commences its cyclic execution. A configuration pragma Cyclic_Execu- tion_Start_Offset delays the start time by the provided amount if an application needs more time to initialise the system:
pragma Cyclic_Execution_Start_Offset (Ada.Real_Time.Time_Span);
remark In many cases it would make sense for the common start time to be the time when all cyclic tasks have finished their initialisation. However, it is hard to provide a generalised solution which would work for applications where the quantity of cyclic tasks remains unknown until run-time. Without knowing the number of cyclic tasks at compile time, the only solution would be to wait for currently initialising tasks to complete. However, the possibility exists for a set of initialising tasks to all complete before the creation of further cyclic tasks, leading the system to commence cyclic execution earlier than expected.
Attribute: T'Cyclic_Task Aspect: Cyclic_Task
Type: Ada.Cyclic_Tasks.Task_Kind
Type Definition Task_Kind is (Yielding, Periodic, Aperiodic, Sporadic, False); Default: False
Valid any task type, read-only at run-time
Defines whether a task is cyclic and, if so, the type of cycle event which triggers the execution of cycle. If a task has cyclic statements, it shall have a non-False Cyclic_Task aspect on the task type. Conversely, a task without cyclic state- ments shall only have a Cyclic_Task aspect if it is False or not have the aspect specified at all. Any other scenario is erroneous.
The Task_Kind type describes the five different kinds of cyclic tasks available:
Yielding The task yields the processor before commencing a new cycle. Periodic The run-time generates cycle events for the task at fixed periodic
intervals, determined by the task’s Cycle_Period attribute. Aperiodic Cycle events raised by new_cycle_statement.
Sporadic The new_cycle_statement raises a cycle event, but not within the interval defined by the time of the last cycle event and the task’s
Cycle_MIT attribute.
False Indicates the task is a sequential task. While the absence of the Cyclic_ Task aspect would be sufficient to indicate a sequential task, providing
False enables users to call T'Cyclic_Task on any task. cyclic execution start
time
cyclic task
Unlike other task attributes, the Cycle_Task attribute is not modifiable at run- time. Consequently, the compiler or run-time may use different data-structures to implement the different task kinds.
Attribute: T'Cycle_Phase Aspect: Cycle_Phase
Type: Ada.Real_Time.Time_Span Default: Ada.Real_Time.Time_Span_Zero
Valid: T'Cyclic_Task /= False, Time_Span >= Time_Span_Zero
The non-negative offset added to Cyclic_Execution_Start_Time, resulting in the earliest time the first cycle event for the task may be raised. For periodic tasks, the first cycle event shall be raised at this time.
Attribute: T'Cycle_Period Aspect: Cycle_Period
Type: Ada.Real_Time.Time_Span Default: Ada.Real_Time.Time_Span_Last
Valid: T'Cyclic_Task = Periodic, Time_Span >= Time_Span_Zero
The non-negative timespan between successive run-time generated cycle events. The default value permits postponing the setting of the attribute until run-time. If the restriction No_Dependence => Ada.Cyclic_Tasks.Dynamics is present, then the Cycle_Period aspect shall be specified on the type.
Attribute: T'Cycle_MIT Aspect: Cycle_MIT
Type: Ada.Real_Time.Time_Span Default: Ada.Real_Time.Time_Span_Last
Valid: T'Cyclic_Task = Sporadic, Time_Span >= Time_Span_Zero
The interval from the last cycle event that a subsequent cycle event shall not be raised in. The default value permits postponing the setting of the attribute until run-time. If the restriction No_Dependence => Ada.Cyclic_Tasks.Dynamics is present, then the Cycle_MIT aspect shall be specified on the type.
Attribute: T'Early_Event_Response Aspect: Early_Event_Response
Type: Ada.Cyclic_Tasks.Early_Event_Responses
Type Definition Early_Event_Responses is (Raise_Exception, Delay, Ignore); Default: Raise_Exception
Valid: T'Cyclic_Task = Sporadic | Aperiodic
The attribute determines the run-time response to an event being raised inside a sporadic task’s MIT interval or while an aperiodic or sporadic task is currently executing a cycle:
Raise_Exception The new_cycle_statement raises Tasking_Error. Ignore The event is silently ignored.
cycle phase
cycle period
cycle minimum inter- arrival time
early event response
45 THE CYCLIC TASK SPECIFICATION
Delay The event is delayed until the end of the sporadic task’s MIT or the cycle completes, whichever comes latter. If a task has an existing delayed event, any further cycle events are dropped.
Attribute: T'Relative_Deadline Aspect: Relative_Deadline
Type: Ada.Real_Time.Time_Span Default: Ada.Real_Time.Time_Span_Last
Valid: any task type, Time_Span >= Time_Span_Zero
The interval a cycle has to complete in from the time of the cycle’s event. A value of Time_Span_Last indicates the task does not have a relative deadline.
For sequential tasks, the attribute sets the initial absolute deadline for the task based on when the task finishes activating.
Attribute: T'Absolute_Deadline Type: Ada.Real_Time.Time Valid: any task type
For cyclic tasks, the time the current cycle shall complete by. For sequential tasks, the time the task shall complete or update the attribute by.
Attribute: T'Execution_Budget Aspect: Execution_Budget
Type: Ada.Real_Time.Time_Span Default: Ada.Real_Time.Time_Span_Last
Valid: any task type, Time_Span >= Time_Span_Zero
The amount of execution time a cycle or sequential task may run for. A task is said to consume its execution budget. A value of Time_Span_Last indicates the task has no execution budget and can consume unlimited processor time.
Attribute: T'Remaining_Execution_Budget
Type: Ada.Real_Time.Time_Span Valid: any task type
Returns the amount of execution budget a sequential task or cycle has left.
Attribute: T'Deadline_Response, T'Budget_Response
Aspect: Deadline_Response, Budget_Reponse Type: Ada.Cyclic_Tasks.Violation_Response
Type Definition Violation_Response is (Ignore, Handler, Abort_Cycle, Abort_Task); Default: Ignore
Valid: any task type
The run-time responds to two different timing violations: missed deadlines and execution budget exhaustions. The Deadline_Response and Budget_Response
attributes set how the run-time responds to these timing violations respectively. A common type — Timing_Violation_Responses — provides four responses: relative deadline absolute deadline execution budget remaining execution budget deadline response budget response 46 CHAPTER 3
Ignore The run-time ignores the timing violation.
Handler The run-time calls the protected procedure handler specified by the corresponding Deadline_Handler or Budget_Handler attribute. Abort_Cycle For a cyclic task, the current cycle is aborted using Ada’s Abort
of a Sequence of Statement semantics (ARM 9.8) and the task waits
for the next cycle event. Not valid for sequential tasks.
Abort_Task The task is aborted with Ada’s Abort of a Task semantics (ARM 9.8). Attribute: T'Deadline_Handler, T'Budget_Handler
Aspect: Deadline_Handler, Budget_Handler Type: Ada.Cyclic_Tasks.Response_Handler
Type Definition access protected procedure (T : Ada.Task_Indentification.Task_Id); Default: null
Valid: T'Deadline_Response = Handler, T'Budget_Response = Handler The protected procedure called by the run-time if the corresponding _Response
attribute is set to Handler. If a task has a _Response aspect set to Handler then the corresponding _Handler shall be set.
The handler is passed the Task_Id of the task causing the timing violation to allow a handler to be shared amongst a set of tasks.
Attribute: T'Execution_Server Aspect: Execution_Server
Type: Ada.Execution_Servers.Execution_Server
Type Definition Execution_Server (<>) is abstract tagged limited private; Default: Ada.Execution_Server.No_Server
Valid: any task type
Specifies the execution server the task will be attached to after activation. Without the cyclic section, the semantics of a task remains unchanged from Ada 2012. With the cyclic section, the semantics of the task becomes:
▶ The sequential_sequence_of_statements executes after the activation of the task in accordance with the selected task dispatching policy. The sequential section allows the user to initialise the task before the
cyclic execution begins.
▶ A task body with a cyclic_sequence_of_statements shall have a non-
FalseCyclic_Task aspect applied to the task type. ▶ Under normal operation, the task will not terminate.
▶ A task body’s exception_handler s shall handle exceptions raised from the sequential_sequence_of_statements and sequential_sequence_ of_statements. The task will terminate after the handler completes.
deadline handler budget handler
execution server