PR c++/37276
[official-gcc.git] / gcc / ada / s-tasini.ads
blob70dd867a342c5b6fbb0b76c63767baec28db1559
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . T A S K I N G . I N I T I A L I Z A T I O N --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2012, Free Software Foundation, Inc. --
10 -- --
11 -- GNARL is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNARL was developed by the GNARL team at Florida State University. --
28 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
29 -- --
30 ------------------------------------------------------------------------------
32 -- This package provides overall initialization of the tasking portion of the
33 -- RTS. This package must be elaborated before any tasking features are used.
35 package System.Tasking.Initialization is
37 procedure Remove_From_All_Tasks_List (T : Task_Id);
38 -- Remove T from All_Tasks_List. Call this function with RTS_Lock taken
40 ---------------------------------
41 -- Tasking-Specific Soft Links --
42 ---------------------------------
44 -- These permit us to leave out certain portions of the tasking
45 -- run-time system if they are not used. They are only used internally
46 -- by the tasking run-time system.
48 -- So far, the only example is support for Ada.Task_Attributes
50 type Proc_T is access procedure (T : Task_Id);
52 procedure Finalize_Attributes (T : Task_Id);
53 procedure Initialize_Attributes (T : Task_Id);
55 Finalize_Attributes_Link : Proc_T := Finalize_Attributes'Access;
56 -- should be called with abort deferred and T.L write-locked
58 Initialize_Attributes_Link : Proc_T := Initialize_Attributes'Access;
59 -- should be called with abort deferred, but holding no locks
61 -------------------------
62 -- Abort Defer/Undefer --
63 -------------------------
65 -- Defer_Abort defers the effects of low-level abort and priority change
66 -- in the calling task until a matching Undefer_Abort call is executed.
68 -- Undefer_Abort DOES MORE than just undo the effects of one call to
69 -- Defer_Abort. It is the universal "polling point" for deferred
70 -- processing, including the following:
72 -- 1) base priority changes
74 -- 2) abort/ATC
76 -- Abort deferral MAY be nested (Self_ID.Deferral_Level is a count), but
77 -- to avoid waste and undetected errors, it generally SHOULD NOT be
78 -- nested. The symptom of over-deferring abort is that an exception may
79 -- fail to be raised, or an abort may fail to take place.
81 -- Therefore, there are two sets of the inlineable defer/undefer routines,
82 -- which are the ones to be used inside GNARL. One set allows nesting. The
83 -- other does not. People who maintain the GNARL should try to avoid using
84 -- the nested versions, or at least look very critically at the places
85 -- where they are used.
87 -- In general, any GNARL call that is potentially blocking, or whose
88 -- semantics require that it sometimes raise an exception, or that is
89 -- required to be an abort completion point, must be made with abort
90 -- Deferral_Level = 1.
92 -- In general, non-blocking GNARL calls, which may be made from inside a
93 -- protected action, are likely to need to allow nested abort deferral.
95 -- With some critical exceptions (which are supposed to be documented),
96 -- internal calls to the tasking runtime system assume abort is already
97 -- deferred, and do not modify the deferral level.
99 -- There is also a set of non-inlineable defer/undefer routines, for direct
100 -- call from the compiler. These are not inlineable because they may need
101 -- to be called via pointers ("soft links"). For the sake of efficiency,
102 -- the version with Self_ID as parameter should used wherever possible.
103 -- These are all nestable.
105 -- Non-nestable inline versions
107 procedure Defer_Abort (Self_ID : Task_Id);
108 pragma Inline (Defer_Abort);
110 procedure Undefer_Abort (Self_ID : Task_Id);
111 pragma Inline (Undefer_Abort);
113 -- Nestable inline versions
115 procedure Defer_Abort_Nestable (Self_ID : Task_Id);
116 pragma Inline (Defer_Abort_Nestable);
118 procedure Undefer_Abort_Nestable (Self_ID : Task_Id);
119 pragma Inline (Undefer_Abort_Nestable);
121 procedure Do_Pending_Action (Self_ID : Task_Id);
122 -- Only call with no locks, and when Self_ID.Pending_Action = True Perform
123 -- necessary pending actions (e.g. abort, priority change). This procedure
124 -- is usually called when needed as a result of calling Undefer_Abort,
125 -- although in the case of e.g. No_Abort restriction, it can be necessary
126 -- to force execution of pending actions.
128 function Check_Abort_Status return Integer;
129 -- Returns Boolean'Pos (True) iff abort signal should raise
130 -- Standard'Abort_Signal. Only used by IRIX currently.
132 --------------------------
133 -- Change Base Priority --
134 --------------------------
136 procedure Change_Base_Priority (T : Task_Id);
137 -- Change the base priority of T. Has to be called with the affected
138 -- task's ATCB write-locked. May temporarily release the lock.
140 ----------------------
141 -- Task Lock/Unlock --
142 ----------------------
144 procedure Task_Lock (Self_ID : Task_Id);
145 pragma Inline (Task_Lock);
147 procedure Task_Unlock (Self_ID : Task_Id);
148 pragma Inline (Task_Unlock);
149 -- These are versions of Lock_Task and Unlock_Task created for use
150 -- within the GNARL.
152 procedure Final_Task_Unlock (Self_ID : Task_Id);
153 -- This version is only for use in Terminate_Task, when the task is
154 -- relinquishing further rights to its own ATCB. There is a very
155 -- interesting potential race condition there, where the old task may run
156 -- concurrently with a new task that is allocated the old tasks (now
157 -- reused) ATCB. The critical thing here is to not make any reference to
158 -- the ATCB after the lock is released. See also comments on
159 -- Terminate_Task and Unlock.
161 procedure Wakeup_Entry_Caller
162 (Self_ID : Task_Id;
163 Entry_Call : Entry_Call_Link;
164 New_State : Entry_Call_State);
165 pragma Inline (Wakeup_Entry_Caller);
166 -- This is called at the end of service of an entry call, to abort the
167 -- caller if he is in an abortable part, and to wake up the caller if he
168 -- is on Entry_Caller_Sleep. Call it holding the lock of Entry_Call.Self.
170 -- Timed_Call or Simple_Call:
171 -- The caller is waiting on Entry_Caller_Sleep, in Wait_For_Completion,
172 -- or Wait_For_Completion_With_Timeout.
174 -- Conditional_Call:
175 -- The caller might be in Wait_For_Completion,
176 -- waiting for a rendezvous (possibly requeued without abort) to
177 -- complete.
179 -- Asynchronous_Call:
180 -- The caller may be executing in the abortable part an async. select,
181 -- or on a time delay, if Entry_Call.State >= Was_Abortable.
183 procedure Locked_Abort_To_Level
184 (Self_ID : Task_Id;
185 T : Task_Id;
186 L : ATC_Level);
187 pragma Inline (Locked_Abort_To_Level);
188 -- Abort a task to a specified ATC level. Call this only with T locked
190 end System.Tasking.Initialization;