Lady Ada

Ada '83 Language Reference Manual

Copyright 1980, 1982, 1983 owned by the United States Government. Direct reproduction and usage requests to the Ada Information Clearinghouse.

9.8. Priorities


Each task may (but need not) have a priority, which is a value of the subtype PRIORITY (of the type INTEGER) declared in the predefined library package SYSTEM (see 13.7). A lower value indicates a lower degree of urgency; the range of priorities is implementation-defined. A priority is associated with a task if a pragma

    pragma PRIORITY (static_expression); 

appears in the corresponding task specification; the priority is given by the value of the expression. A priority is associated with the main program if such a pragma appears in its outermost declarative part. At most one such pragma can appear within a given task specification or for a subprogram that is a library unit, and these are the only allowed places for this pragma. A pragma PRIORITY has no effect if it occurs in a subprogram other than the main program.

The specification of a priority is an indication given to assist the implementation in the allocation of processing resources to parallel tasks when there are more tasks eligible for execution than can be supported simultaneously by the available processing resources. The effect of priorities on scheduling is defined by the following rule:

     If two tasks with different priorities are both eligible for execution
     and could sensibly be executed using the same physical processors  and
     the  same  other processing resources, then it cannot be the case that
     the task with the lower priority is executing while the task with  the
     higher priority is not.                                                       

For tasks of the same priority, the scheduling order is not defined by the language. For tasks without explicit priority, the scheduling rules are not defined, except when such tasks are engaged in a rendezvous. If the priorities of both tasks engaged in a rendezvous are defined, the rendezvous is executed with the higher of the two priorities. If only one of the two priorities is defined, the rendezvous is executed with at least that priority. If neither is defined, the priority of the rendezvous is undefined.


The priority of a task is static and therefore fixed. However, the priority during a rendezvous is not necessarily static since it also depends on the priority of the task calling the entry. Priorities should be used only to indicate relative degrees of urgency; they should not be used for task synchronization.

References: declarative part, entry call statement, integer type, main program, package system, pragma, rendezvous, static expression, subtype, task, task specification.

Rationale references: 13.2.2 Task Execution, 13.2.8 Interrupts

Style Guide references: 6.1.4 Priorities, 7.4.5 Task Scheduling Algorithm, 8.4.2 Coupling Due to Pragmas


[Ada Information Clearinghouse]

Address any questions or comments to