D.5 Dynamic Priorities
This Reference Manual output has not been verified, and may contain omissions or errors. Report any problems on the tracking issue
[This subclause describes how the priority of an entity can be modified or queried at run time.]
Wording Changes from Ada 95
D.5.1 Dynamic Priorities for Tasks
1/3[This subclause describes how the base priority of a task can be modified or queried at run time.]
Static Semantics
2The following language-defined library package exists:
with System;
with Ada.Task_Identification; -- See C.7.1
package Ada.Dynamic_Priorities
with Preelaborate, Nonblocking, Global => in out synchronized is
4procedure Set_Priority(Priority : in System.Any_Priority;
T : in Ada.Task_Identification.Task_Id :=
Ada.Task_Identification.Current_Task);
5function Get_Priority (T : Ada.Task_Identification.Task_Id :=
Ada.Task_Identification.Current_Task)
return System.Any_Priority;
6end Ada.Dynamic_Priorities;
Dynamic Semantics
7The 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.
The function Get_Priority returns T's current base priority. Tasking_Error is raised if the task is terminated.
Program_Error is raised by Set_Priority and Get_Priority if T is equal to Null_Task_Id.
On a system with a single processor, the setting of the base priority of a task T to the new value occurs immediately at the first point when T is outside the execution of a protected action.
- The check was not feasible to implement on all systems, since priority changes might be deferred due to inter-processor communication overhead. The calling task would continue to execute without finding out whether the operation succeeded or not.
- The runtime check would tend to cause intermittent system failures — how is the caller supposed to know whether the other task happens to have a queued call at any given time? Consider for example an interrupt that needs to trigger a priority change in some task. The interrupt handler could not safely call Set_Priority without knowing exactly what the other task is doing, or without severely restricting the ceilings used in the system. If the interrupt handler wants to hand the job off to a third task whose job is to call Set_Priority, this won't help, because one would normally want the third task to have high priority.
Paragraph 11 was deleted.
Erroneous Execution
12If 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/2On a multiprocessor, the implementation shall document any conditions that cause the completion of the setting of the priority of a task to be delayed later than what is specified for a single processor.
Metrics
13The implementation shall document the following metric:
- The execution time of a call to Set_Priority, for the nonpreempting case, in processor clock cycles. This is measured for a call that modifies the priority of a ready task that is not running (which cannot be the calling one), where the new base priority of the affected task is lower than the active priority of the calling task, and the affected task is not on any entry queue and is not executing a protected operation.
triggering_statement
of an asynchronous_select
.Extensions to Ada 95
Wording Changes from Ada 95
D.5.2 Dynamic Priorities for Protected Objects
1/3This subclause specifies how the priority of a protected object can be modified or queried at run time.
Static Semantics
2/5The following attributes are defined for a prefix
P that denotes a protected object:
P'Priority
- Denotes a non-aliased component of the protected object P. This component is of type System.Any_Priority and its value is the priority of P. P'Priority denotes a variable if and only if P denotes a variable. A reference to this attribute shall appear only within the body of P.
P'Relative_Deadline- Denotes a non-aliased component of the protected object P. This component is of type Ada.Real_Time.Time_Span and its value is the relative deadline of P. P'Relative_Deadline denotes a variable if and only if P denotes a variable. A reference to this attribute shall appear only within the body of P.
The initial value of the attribute Priority is determined by the initial value of the priority of the protected object (see D.3)[, and can be changed by an assignment]. The initial value of the attribute Relative_Deadline is determined by the initial value of the relative deadline of the protected object (see D.3)[, and can be changed by an assignment].
Dynamic Semantics
5/3If the locking policy Ceiling_Locking (see D.3) is in effect, then the ceiling priority of a protected object P is set to the value of P'Priority at the end of each protected action of P.
If the locking policy Ceiling_Locking is in effect, then for a protected object P with either an Attach_Handler or Interrupt_Handler aspect specified for one of its procedures, a check is made that the value to be assigned to P'Priority is in the range System.Interrupt_Priority. If the check fails, Program_Error is raised.
Metrics
7/2The implementation shall document the following metric:
- The difference in execution time of calls to the following procedures in protected object P:
protected P is
procedure Do_Not_Set_Ceiling (Pr : System.Any_Priority);
procedure Set_Ceiling (Pr : System.Any_Priority);
end P;
10/2protected body P is
procedure Do_Not_Set_Ceiling (Pr : System.Any_Priority) is
begin
null;
end;
procedure Set_Ceiling (Pr : System.Any_Priority) is
begin
P'Priority := Pr;
end;
end P;