Contents   Index   Search   Related Documents   Previous   Next


D.5.1 Dynamic Priorities for Tasks

1
   This clause specifies how the base priority of a task can be modified or queried at run time.

Static Semantics

2
   The following language-defined library package exists:
3/2
with System;
with Ada.Task_Identification; -- See C.7.1
package Ada.Dynamic_Priorities is
    pragma Preelaborate(Dynamic_Priorities);
4
    procedure Set_Priority(Priority : in System.Any_Priority;
                           T : in Ada.Task_Identification.Task_Id :=
                           Ada.Task_Identification.Current_Task);
5
    function Get_Priority (T : Ada.Task_Identification.Task_Id :=
                           Ada.Task_Identification.Current_Task)
                           return System.Any_Priority;
6
end Ada.Dynamic_Priorities;

Dynamic Semantics

7
   The procedure Set_Priority sets the base priority of the specified task to the specified Priority value. Set_Priority has no effect if the task is terminated.
8
   The function Get_Priority returns T's current base priority. Tasking_Error is raised if the task is terminated.
9
   Program_Error is raised by Set_Priority and Get_Priority if T is equal to Null_Task_Id.
10/2
      On a system with a single processor, the setting of a task's base priority to the new value occurs immediately at the first point that is outside the execution of an abort-deferred operation.

Bounded (Run-Time) Errors

11/2
      This paragraph was deleted.

Erroneous Execution

12
    If any subprogram in this package is called with a parameter T that specifies a task object that no longer exists, the execution of the program is erroneous.

Documentation Requirements

12.1/2
        On a multiprocessor, the implementation shall document any conditions that cause the completion of the setting of a task's priority to be delayed later than what is specified for a single processor.

Metrics

13
    The implementation shall document the following metric:
14
NOTES
15
29  Setting a task's base priority affects task dispatching. First, it can change the task's active priority. Second, under the standard task dispatching policy it always causes the task to move to the tail of the ready queue corresponding to its active priority, even if the new base priority is unchanged.
16
30  Under the priority queuing policy, setting a task's base priority has an effect on a queued entry call if the task is blocked waiting for the call. That is, setting the base priority of a task causes the priority of a queued entry call from that task to be updated and the call to be removed and then reinserted in the entry queue at the new priority (see D.4), unless the call originated from the triggering_statement of an asynchronous_select.
17
31  The effect of two or more Set_Priority calls executed in parallel on the same task is defined as executing these calls in some serial order.
18
32  The rule for when Tasking_Error is raised for Set_Priority or Get_Priority is different from the rule for when Tasking_Error is raised on an entry call (see 9.5.3). In particular, setting or querying the priority of a completed or an abnormal task is allowed, so long as the task is not yet terminated.
19
33  Changing the priorities of a set of tasks can be performed by a series of calls to Set_Priority for each task separately. For this to work reliably, it should be done within a protected operation that has high enough ceiling priority to guarantee that the operation completes without being preempted by any of the affected tasks.

Contents   Index   Search   Related Documents   Previous   Next   Legal