Go to the first, previous, next, last section, table of contents.


D.1 Task Priorities

  1. This clause specifies the priority model for real-time systems. In addition, the methods for specifying priorities are defined.

    Syntax

  2. The form of a pragma Priority is as follows:
  3. pragma Priority(expression);
    
  4. The form of a pragma Interrupt_Priority is as follows:
  5. pragma Interrupt_Priority[(expression)];
    

    Name Resolution Rules

  6. The expected type for the expression in a Priority or Interrupt_Priority pragma is Integer.

    Legality Rules

  7. A Priority pragma is allowed only immediately within a task_definition, a protected_definition, or the declarative_part of a subprogram_body. An Interrupt_Priority pragma is allowed only immediately within a task_ definition or a protected_definition. At most one such pragma shall appear within a given construct.
  8. For a Priority pragma that appears in the declarative_part of a subprogram_body, the expression shall be static, and its value shall be in the range of System.Priority.

    Static Semantics

  9. The following declarations exist in package System:
  10. subtype Any_Priority is Integer range implementation-defined;
    subtype Priority is Any_Priority range
      Any_Priority'First .. implementation-defined;
    subtype Interrupt_Priority is Any_Priority range
      Priority'Last+1 .. Any_Priority'Last;
    
  11. Default_Priority : constant Priority
      := (Priority'First + Priority'Last)/2;
    
  12. The full range of priority values supported by an implementation is specified by the subtype Any_Priority. The subrange of priority values that are high enough to require the blocking of one or more interrupts is specified by the subtype Interrupt_Priority. The subrange of priority values below System.Interrupt_Priority'First is specified by the subtype System.Priority.
  13. The priority specified by a Priority or Interrupt_Priority pragma is the value of the expression in the pragma, if any. If there is no expression in an Interrupt_Priority pragma, the priority value is Interrupt_Priority'Last.

    Dynamic Semantics

  14. A Priority pragma has no effect if it occurs in the declarative_part of the subprogram_body of a subprogram other than the main subprogram.
  15. A task priority is an integer value that indicates a degree of urgency and is the basis for resolving competing demands of tasks for resources. Unless otherwise specified, whenever tasks compete for processors or other implementation-defined resources, the resources are allocated to the task with the highest priority value. The base priority of a task is the priority with which it was created, or to which it was later set by Dynamic_Priorities.Set_Priority, See section D.5 Dynamic Priorities. At all times, a task also has an active priority, which generally reflects its base priority as well as any priority it inherits from other sources. Priority inheritance is the process by which the priority of a task or other entity (e.g. a protected object; See section D.3 Priority Ceiling Locking.) is used in the evaluation of another task's active priority.
  16. The effect of specifying such a pragma in a protected_definition is discussed in See section D.3 Priority Ceiling Locking.
  17. The expression in a Priority or Interrupt_Priority pragma that appears in a task_definition is evaluated for each task object, See section 9.1 Task Units and Task Objects. For a Priority pragma, the value of the expression is converted to the subtype Priority; for an Interrupt_Priority pragma, this value is converted to the subtype Any_Priority. The priority value is then associated with the task object whose task_definition contains the pragma.
  18. Likewise, the priority value is associated with the environment task if the pragma appears in the declarative_part of the main subprogram.
  19. The initial value of a task's base priority is specified by default or by means of a Priority or Interrupt_Priority pragma. After a task is created, its base priority can be changed only by a call to Dynamic_Priorities.Set_Priority, See section D.5 Dynamic Priorities. The initial base priority of a task in the absence of a pragma is the base priority of the task that creates it at the time of creation, See section 9.1 Task Units and Task Objects. If a pragma Priority does not apply to the main subprogram, the initial base priority of the environment task is System.Default_Priority. The task's active priority is used when the task competes for processors. Similarly, the task's active priority is used to determine the task's position in any queue when Priority_Queuing is specified, See section D.4 Entry Queuing Policies.
  20. At any time, the active priority of a task is the maximum of all the priorities the task is inheriting at that instant. For a task that is not held, See section D.11 Asynchronous Task Control, its base priority is always a source of priority inheritance. Other sources of priority inheritance are specified under the following conditions:
    1. During activation, a task being activated inherits the active priority of the its activator, See section 9.2 Task Execution - Task Activation.
    2. During rendezvous, the task accepting the entry call inherits the active priority of the caller, See section 9.5.3 Entry Calls.
    3. During a protected action on a protected object, a task inherits the ceiling priority of the protected object, See section 9.5 Intertask Communication, and See section D.3 Priority Ceiling Locking.

  1. In all of these cases, the priority ceases to be inherited as soon as the condition calling for the inheritance no longer exists.

    Implementation Requirements

  2. The range of System.Interrupt_Priority shall include at least one value.
  3. The range of System.Priority shall include at least 30 values.

    NOTES

  4. (4) The priority expression can include references to discriminants of the enclosing type.
  5. (5) It is a consequence of the active priority rules that at the point when a task stops inheriting a priority from another source, its active priority is re-evaluated. This is in addition to other instances described in this Annex for such re-evaluation.
  6. (6) An implementation may provide a non-standard mode in which tasks inherit priorities under conditions other than those specified above.


Go to the first, previous, next, last section, table of contents.