D.2.5 Round Robin Dispatching
1/2
{
AI95-00355-01}
[This clause defines the task dispatching policy
Round_Robin_Within_Priorities and the package Round_Robin.]
Static Semantics
2/2
3/2
{
AI95-00355-01}
The following language-defined library package
exists:
4/2
with System;
with Ada.Real_Time;
package Ada.Dispatching.Round_Robin is
Default_Quantum : constant Ada.Real_Time.Time_Span :=
implementation-defined;
procedure Set_Quantum (Pri : in System.Priority;
Quantum : in Ada.Real_Time.Time_Span);
procedure Set_Quantum (Low, High : in System.Priority;
Quantum : in Ada.Real_Time.Time_Span);
function Actual_Quantum (Pri : System.Priority)
return Ada.Real_Time.Time_Span;
function Is_Round_Robin (Pri : System.Priority) return Boolean;
end Ada.Dispatching.Round_Robin;
4.a.1/2
Implementation defined:
The value of Default_Quantum in Dispatching.Round_Robin.
5/2
{
AI95-00355-01}
When task dispatching policy Round_Robin_Within_Priorities
is the single policy in effect for a partition, each task with priority
in the range of System.Interrupt_Priority is dispatched according to
policy FIFO_Within_Priorities.
Dynamic Semantics
6/2
{
AI95-00355-01}
The procedures Set_Quantum set the required Quantum
value for a single priority level Pri or a range of priority levels Low
.. High. If no quantum is set for a Round Robin priority level, Default_Quantum
is used.
7/2
{
AI95-00355-01}
The function Actual_Quantum returns the actual
quantum used by the implementation for the priority level Pri.
8/3
{
AI95-00355-01}
{
AI05-0264-1}
The function Is_Round_Robin returns True if priority
Pri is covered by task dispatching policy Round_Robin_Within_Priorities;
otherwise, it returns False.
9/2
{
AI95-00355-01}
A call of Actual_Quantum or Set_Quantum raises
exception Dispatching.Dispatching_Policy_Error if a predefined policy
other than Round_Robin_Within_Priorities applies to the specified priority
or any of the priorities in the specified range.
10/2
{
AI95-00355-01}
For Round_Robin_Within_Priorities, the dispatching
rules for FIFO_Within_Priorities apply with the following additional
rules:
11/2
When a task is added or moved
to the tail of the ready queue for its base priority, it has an execution
time budget equal to the quantum for that priority level. This will also
occur when a blocked task becomes executable again.
12/2
When a task is preempted
(by a higher priority task) and is added to the head of the ready queue
for its priority level, it retains its remaining budget.
13/2
While a task is executing,
its budget is decreased by the amount of execution time it uses. The
accuracy of this accounting is the same as that for execution time clocks
(see D.14).
13.a/2
Ramification: Note
that this happens even when the task is executing at a higher, inherited
priority, and even if that higher priority is dispatched by a different
policy than round robin.
14/2
When a task has exhausted
its budget and is without an inherited priority (and is not executing
within a protected operation), it is moved to the tail of the ready queue
for its priority level. This is a task dispatching point.
14.a/2
Ramification: In
this case, it will be given a budget as described in the first bullet.
14.b/2
The rules for FIFO_Within_Priority
(to which these bullets are added) say that a task that has its base
priority set to a Round Robin priority is moved to the tail of the ready
queue for its new priority level, and then will be given a budget as
described in the first bullet. That happens whether or not the task's
original base priority was a Round Robin priority.
Implementation Requirements
15/2
{
AI95-00333-01}
{
AI95-00355-01}
An implementation shall allow, for a single partition,
both the task dispatching policy to be specified as Round_Robin_Within_Priorities
and also the locking policy (see D.3) to be
specified as Ceiling_Locking.
15.a/2
Reason: This is
the preferred combination of the Round_Robin_Within_Priorities policy
with a locking policy, and we want that combination to be portable.
Documentation Requirements
16/2
{
AI95-00355-01}
An implementation shall document the quantum values
supported.
16.a.1/2
Documentation Requirement:
The quantum values supported for round
robin dispatching.
17/2
{
AI95-00355-01}
An implementation shall document the accuracy with
which it detects the exhaustion of the budget of a task.
17.a.1/2
Documentation Requirement:
The accuracy of the detection of the
exhaustion of the budget of a task for round robin dispatching.
18/2
19 {
AI95-00355-01}
Due to implementation constraints, the quantum
value returned by Actual_Quantum might not be identical to that set with
Set_Quantum.
19/2
20 {
AI95-00355-01}
A task that executes continuously with an inherited
priority will not be subject to round robin dispatching.
Extensions to Ada 95
19.a/2
{
AI95-00355-01}
Policy Round_Robin_Within_Priorities
and package Dispatching.Round_Robin are new.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe