D.10 Synchronous Task Control
This Reference Manual output has not been verified, and may contain omissions or errors. Report any problems on the tracking issue
[This subclause describes a language-defined private semaphore (suspension object), which can be used for two-stage suspend operations and as a simple building block for implementing higher-level queues.]
The following language-defined package exists:
package Ada.Synchronous_Task_Control with Preelaborate, Nonblocking, Global => in out synchronized is 4/5type Suspension_Object is limited private; procedure Set_True(S : in out Suspension_Object); procedure Set_False(S : in out Suspension_Object); function Current_State(S : Suspension_Object) return Boolean; procedure Suspend_Until_True(S : in out Suspension_Object) with Nonblocking => False; private ... -- not specified by the language end Ada.Synchronous_Task_Control;
The type Suspension_Object is a by-reference type.
The following language-defined package exists:
with Nonblocking, Global => in out synchronized is
(S : in out Suspension_Object;
TS : in Ada.Real_Time.Time_Span)
with Nonblocking => False;
An object of the type Suspension_Object has two visible states: True and False. Upon initialization, its value is set to False.
The operations Set_True and Set_False are atomic with respect to each other and with respect to Suspend_Until_True; they set the state to True and False respectively.
Current_State returns the current state of the object.
The procedure Suspend_Until_True blocks the calling task until the state of the object S is True; at that point the task becomes ready and the state of the object becomes False.
Program_Error is raised upon calling Suspend_Until_True if another task is already waiting on that suspension object.
The procedure Suspend_Until_True_And_Set_Deadline blocks the calling task until the state of the object S is True; at that point the task becomes ready with a deadline of Ada.Real_Time.Clock + TS, and the state of the object becomes False. Program_Error is raised upon calling Suspend_Until_True_And_Set_Deadline if another task is already waiting on that suspension object.
Bounded (Run-Time) Errors10.2/5
It is a bounded error for two or more tasks to call Suspend_Until_True on the same Suspension_Object concurrently. For each task, Program_Error can be raised, the task can proceed without suspending, or the task can suspend, potentially indefinitely. The state of the suspension object can end up either True or False.
The implementation is required to allow the calling of Set_False and Set_True during any protected action, even one that has its ceiling priority in the Interrupt_Priority range.
Extensions to Ada 95
Extensions to Ada 2005
Wording Changes from Ada 2012
D.10.1 Synchronous Barriers1/3
This subclause introduces a language-defined package to synchronously release a group of tasks after the number of blocked tasks reaches a specified count value.
The following language-defined library package exists:
package Ada.Synchronous_Barriers with Preelaborate, Nonblocking, Global => in out synchronized is 4/3subtype Barrier_Limit is Positive range 1 .. implementation-defined;
type Synchronous_Barrier (Release_Threshold : Barrier_Limit) is limited private; 6/5procedure Wait_For_Release (The_Barrier : in out Synchronous_Barrier; Notified : out Boolean) with Nonblocking => False; 7/3private -- not specified by the language end Ada.Synchronous_Barriers;
Type Synchronous_Barrier needs finalization (see 7.6).
Each call to Wait_For_Release blocks the calling task until the number of blocked tasks associated with the Synchronous_Barrier object is equal to Release_Threshold, at which time all blocked tasks are released. Notified is set to True for one of the released tasks, and set to False for all other released tasks.
The mechanism for determining which task sets Notified to True is implementation defined.
Once all tasks have been released, a Synchronous_Barrier object may be reused to block another Release_Threshold number of tasks.
As the first step of the finalization of a Synchronous_Barrier, each blocked task is unblocked and Program_Error is raised at the place of the call to Wait_For_Release.
It is implementation defined whether an abnormal task which is waiting on a Synchronous_Barrier object is aborted immediately or aborted when the tasks waiting on the object are released.
This paragraph was deleted.
Bounded (Run-Time) Errors15/3
It is a bounded error to call Wait_For_Release on a Synchronous_Barrier object after that object is finalized. If the error is detected, Program_Error is raised. Otherwise, the call proceeds normally, which may leave a task blocked forever.