D.2.2 Task Dispatching Pragmas The Standard Task Dispatching Policy
0.1/2
{
AI95-00355-01}
[This clause allows a single task dispatching policy
to be defined for all priorities, or the range of priorities to be split
into subranges that are assigned individual dispatching policies.]
Syntax
1
The form of
a pragma Task_Dispatching_Policy is as follows:
2
pragma Task_Dispatching_Policy(
policy_identifier);
2.1/2
{
AI95-00355-01}
The form of a pragma
Priority_Specific_Dispatching is as follows:
2.2/2
pragma
Priority_Specific_Dispatching
(
policy_identifier,
first_priority_expression,
last_priority_expression);
Name Resolution Rules
2.3/2
{
AI95-00355-01}
The expected type for first_priority_expression
and last_priority_expression is Integer.
Legality Rules
3/2
{
AI95-00321-01}
{
AI95-00355-01}
The
policy_identifier used
in a pragma Task_Dispatching_Policy shall
be the name of a task dispatching policy shall
either be FIFO_Within_Priorities or an implementation-defined identifier.
3.a/2
This paragraph
was deleted.Implementation defined:
Implementation-defined policy_identifiers
allowed in a pragma Task_Dispatching_Policy.
3.1/2
{
AI95-00355-01}
The policy_identifier
used in a pragma Priority_Specific_Dispatching
shall be the name of a task dispatching policy.
3.2/2
{
AI95-00355-01}
Both first_priority_expression
and last_priority_expression shall
be static expressions in the range of System.Any_Priority; last_priority_expression
shall have a value greater than or equal to first_priority_expression.
Static Semantics
3.3/2
{
AI95-00355-01}
Pragma Task_Dispatching_Policy
specifies the single task dispatching policy.
3.4/2
{
AI95-00355-01}
Pragma Priority_Specific_Dispatching
specifies the task dispatching policy for the specified range of priorities.
Tasks with base priorities within the range of priorities specified in
a Priority_Specific_Dispatching pragma have their active priorities determined
according to the specified dispatching policy. Tasks with active priorities
within the range of priorities specified in a Priority_Specific_Dispatching
pragma are dispatched according to the specified dispatching policy.
3.b/2
Reason: {
AI95-00355-01}
Each ready queue is managed by exactly one policy.
Anything else would be chaos. The ready queue is determined by the active
priority. However, how the active priority is calculated is determined
by the policy; in order to break out of this circle, we have to say that
the active priority is calculated by the method determined by the policy
of the base priority.
3.5/2
{
AI95-00355-01}
If a partition contains one or more Priority_Specific_Dispatching
pragmas the dispatching policy for priorities not covered by any Priority_Specific_Dispatching
pragmas is FIFO_Within_Priorities.
Post-Compilation Rules
4/2
{
AI95-00355-01}
{configuration pragma (Task_Dispatching_Policy)
[partial]} {pragma,
configuration (Task_Dispatching_Policy) [partial]} A
Task_Dispatching_Policy pragma is a configuration pragma.
A Priority_Specific_Dispatching pragma is a configuration pragma. {configuration
pragma (Priority_Specific_Dispatching) [partial]} {pragma,
configuration (Priority_Specific_Dispatching) [partial]}
4.1/2
{
AI95-00355-01}
The priority ranges specified in more than one
Priority_Specific_Dispatching pragma within the same partition shall
not be overlapping.
4.2/2
{
AI95-00355-01}
If a partition contains one or more Priority_Specific_Dispatching
pragmas it shall not contain a Task_Dispatching_Policy pragma.
5/2
This paragraph was
deleted.{
AI95-00333-01}
If the FIFO_Within_Priorities policy is specified
for a partition, then the Ceiling_Locking policy (see D.3)
shall also be specified for the partition.
Dynamic Semantics
6/2
{
AI95-00355-01}
{task dispatching policy}
[A
task dispatching policy specifies the details
of task dispatching that are not covered by the basic task dispatching
model. These rules govern when tasks are inserted into and deleted from
the ready queues
, and whether a task is inserted
at the head or the tail of the queue for its active priority.]
A single The
task dispatching policy is specified by a Task_Dispatching_Policy
configuration
pragma.
Pragma Priority_Specific_Dispatching
assigns distinct dispatching policies to subranges of System.Any_Priority. {unspecified
[partial]} If no such pragma appears in any
of the program units comprising a partition, the task dispatching policy
for that partition is unspecified.
6.1/2
{
AI95-00355-01}
{unspecified
[partial]} If neither pragma
applies to any of the program units comprising a partition, the task
dispatching policy for that partition is unspecified.
6.2/2
{
AI95-00355-01}
If a partition contains one or more Priority_Specific_Dispatching
pragmas a task dispatching point occurs for the currently running task
of a processor whenever there is a non-empty ready queue for that processor
with a higher priority than the priority of the running task.
6.a/2
Discussion: If
we have priority specific dispatching then we want preemption across
the entire range of priorities. That prevents higher priority tasks from
being blocked by lower priority tasks that have a different policy. On
the other hand, if we have a single policy for the entire partition,
we want the characteristics of that policy to apply for preemption; specifically,
we may not require any preemption. Note that policy Non_Preemptive_FIFO_Within_Priorities
is not allowed in a priority specific dispatching pragma.
6.3/2
{
AI95-00355-01}
A task that has its base priority changed may move
from one dispatching policy to another. It is immediately subject to
the new dispatching policy.
6.b/2
Ramification: Once
subject to the new dispatching policy, it may be immediately preempted
or dispatched, according the rules of the new policy.
Paragraphs
7 through 13 were moved to D.2.3.
7/2
{
AI95-00321-01}
The language defines only one task dispatching
policy, FIFO_Within_Priorities; when this policy is in effect, modifications
to the ready queues occur only as follows:
8/2
- {AI95-00321-01}
When a blocked task becomes ready, it is added
at the tail of the ready queue for its active priority.
9/2
- {AI95-00321-01}
When the active priority of a ready task that is
not running changes, or the setting of its base priority takes effect,
the task is removed from the ready queue for its old active priority
and is added at the tail of the ready queue for its new active priority,
except in the case where the active priority is lowered due to the loss
of inherited priority, in which case the task is added at the head of
the ready queue for its new active priority.
10/2
- {AI95-00321-01}
When the setting of the base priority of a running
task takes effect, the task is added to the tail of the ready queue for
its active priority.
11/2
- {AI95-00321-01}
When a task executes a delay_statement
that does not result in blocking, it is added to the tail of the ready
queue for its active priority.
11.a/2
Ramification: If
the delay does result in blocking, the task moves to the “delay
queue”, not to the ready queue.
12/2
{
AI95-00321-01}
{task dispatching
point [partial]} {dispatching
point [partial]} Each of the events specified
above is a task dispatching point (see D.2.1).
13/2
{
AI95-00321-01}
In addition, when a task is preempted, it is added
at the head of the ready queue for its active priority.
Implementation Requirements
13.1/2
{
AI95-00333-01}
{
AI95-00355-01}
An implementation shall allow, for a single partition,
both the locking policy (see D.3) to be specified
as Ceiling_Locking and also one or more Priority_Specific_Dispatching
pragmas to be given.
Documentation Requirements
Paragraphs
14 through 16 were moved to D.2.3.
14/2
{
AI95-00321-01}
{priority inversion}
Priority inversion is the duration for which
a task remains at the head of the highest priority ready queue while
the processor executes a lower priority task. The implementation shall
document:
15/2
- {AI95-00321-01}
The maximum priority inversion a user task can
experience due to activity of the implementation (on behalf of lower
priority tasks), and
16/2
- {AI95-00321-01}
whether execution of a task can be preempted by
the implementation processing of delay expirations for lower priority
tasks, and if so, for how long.
16.a/2
This paragraph
was deleted.Implementation defined:
Implementation-defined aspects of priority
inversion.
Implementation Permissions
17/2
{
AI95-00256-01}
Implementations are allowed to define other task dispatching policies,
but need not support more than one
task dispatching such
policy per partition.
18/2
{
AI95-00355-01}
An implementation need not support pragma
Priority_Specific_Dispatching if it is infeasible to support it in the
target environment. [For optimization purposes,]
an implementation may alter the points at which task dispatching occurs,
in an implementation defined manner. However, a delay_statement
always corresponds to at least one task dispatching point.
18.a
Implementation defined: Implementation
defined task dispatching.
18.b/2
Implementation defined: Implementation
defined task dispatching policies.
Paragraphs
19 through 21 were deleted.
19/2
14 {
AI95-00321-01}
If the active priority of a running task is lowered
due to loss of inherited priority (as it is on completion of a protected
operation) and there is a ready task of the same active priority that
is not running, the running task continues to run (provided that there
is no higher priority task).
20/2
15 {
AI95-00321-01}
The setting of a task's base priority as a result
of a call to Set_Priority does not always take effect immediately when
Set_Priority is called. The effect of setting the task's base priority
is deferred while the affected task performs a protected action.
21/2
16 {
AI95-00321-01}
Setting the base priority of a ready task causes
the task to move to the end of the queue for its active priority, regardless
of whether the active priority of the task actually changes.
Extensions to Ada 95
21.a/2
{
AI95-00333-01}
{extensions to Ada 95} Amendment
Correction: It is no longer required to specify Ceiling_Locking with
the language-defined task dispatching policies; we only require that
implementations allow them to be used together.
21.b/2
{
AI95-00355-01}
Pragma Priority_Specific_Dispatching is
new; it allows specifying different policies for different priorities.
Wording Changes from Ada 95
21.c/2
{
AI95-00256-01}
Clarified that an implementation need support only
one task dispatching policy (of any kind, language-defined or otherwise)
per partition.
21.d/2
{
AI95-00321-01}
This description is simplified to describe only
the rules for the Task_Dispatching_Policy pragma that are common to all
policies. In particular, rules about preemption are moved elsewhere.
This makes it easier to add other policies (which may not involve preemption).