D.16 Multiprocessor Implementation
This subclause allows implementations on multiprocessor
platforms to be configured.
Static Semantics
The following language-defined
library package exists:
package System.Multiprocessors
with Preelaborate, Nonblocking, Global =>
in out synchronized is
type CPU_Range
is range 0 ..
implementation-defined;
Not_A_Specific_CPU :
constant CPU_Range := 0;
subtype CPU
is CPU_Range
range 1 .. CPU_Range'Last;
function Number_Of_CPUs
return CPU;
end System.Multiprocessors;
A call of Number_Of_CPUs returns the number of processors
available to the program. Within a given partition, each call on Number_Of_CPUs
will return the same value.
CPU
The aspect CPU is an
expression,
which shall be of type System.Multiprocessors.CPU_Range.
Legality Rules
If the CPU aspect is specified for a subprogram,
the
expression
shall be static.
The CPU aspect shall not be specified on a task or
protected interface type.
Dynamic Semantics
The
expression
specified for the CPU aspect of a task or protected type is evaluated
each time an object of the corresponding type is created (see
9.1
and
9.4). The CPU value is then associated
with the object.
The CPU aspect has no effect if it is specified for
a subprogram other than the main subprogram; the CPU value is not associated
with any task.
The CPU value is associated with the environment
task if the CPU aspect is specified for the main subprogram. If the CPU
aspect is not specified for the main subprogram it is implementation
defined on which processor the environment task executes.
For a task, the CPU value determines the processor
on which the task will activate and execute; the task is said to be assigned
to that processor. If the CPU value is Not_A_Specific_CPU, then the task
is not assigned to a processor. A task without a CPU aspect specified
will activate and execute on the same processor as its activating task
if the activating task is assigned a processor. If the CPU value is not
in the range of System.Multiprocessors.CPU_Range or is greater than Number_Of_CPUs
the task is defined to have failed, and it becomes a completed task (see
9.2).
For a protected type, the CPU value determines the
processor on which calling tasks will execute; the protected object is
said to be assigned to that processor. If the CPU value is Not_A_Specific_CPU,
then the protected object is not assigned to a processor. A call to a
protected object that is assigned to a processor from a task that is
not assigned a processor or is assigned a different processor raises
Program_Error.
Implementation Advice
Starting a protected action on a protected object
statically assigned to a processor should be implemented without busy-waiting.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe