Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / gcc / ada / s-tasini.ads
blob62bfc0c3463b7fdbed741ff44cff44ae13a7f809
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNU ADA 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-2004, 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 2, or (at your option) any later ver- --
14 -- sion. GNARL 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNARL; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNARL was developed by the GNARL team at Florida State University. --
30 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 -- This package provides overall initialization of the tasking portion of the
35 -- RTS. This package must be elaborated before any tasking features are used.
37 package System.Tasking.Initialization is
39 procedure Remove_From_All_Tasks_List (T : Task_Id);
40 -- Remove T from All_Tasks_List.
41 -- Call this function with RTS_Lock taken.
43 ---------------------------------
44 -- Tasking-Specific Soft Links --
45 ---------------------------------
47 -- These permit us to leave out certain portions of the tasking
48 -- run-time system if they are not used. They are only used internally
49 -- by the tasking run-time system.
50 -- So far, the only example is support for Ada.Task_Attributes.
52 type Proc_T is access procedure (T : Task_Id);
54 procedure Finalize_Attributes (T : Task_Id);
55 procedure Initialize_Attributes (T : Task_Id);
57 Finalize_Attributes_Link : Proc_T := Finalize_Attributes'Access;
58 -- should be called with abortion deferred and T.L write-locked
60 Initialize_Attributes_Link : Proc_T := Initialize_Attributes'Access;
61 -- should be called with abortion deferred, but holding no locks
63 -------------------------
64 -- Abort Defer/Undefer --
65 -------------------------
67 -- Defer_Abort defers the affects of low-level abort and priority change
68 -- in the calling task until a matching Undefer_Abort call is executed.
70 -- Undefer_Abort DOES MORE than just undo the effects of one call to
71 -- Defer_Abort. It is the universal "polling point" for deferred
72 -- processing, including the following:
74 -- 1) base priority changes
76 -- 2) abort/ATC
78 -- Abort deferral MAY be nested (Self_ID.Deferral_Level is a count),
79 -- but to avoid waste and undetected errors, it generally SHOULD NOT
80 -- be nested. The symptom of over-deferring abort is that an exception
81 -- may fail to be raised, or an abort may fail to take place.
83 -- Therefore, there are two sets of the inlinable defer/undefer
84 -- routines, which are the ones to be used inside GNARL.
85 -- One set allows nesting. The other does not. People who
86 -- maintain the GNARL should try to avoid using the nested versions,
87 -- or at least look very critically at the places where they are
88 -- used.
90 -- In general, any GNARL call that is potentially blocking, or
91 -- whose semantics require that it sometimes raise an exception,
92 -- or that is required to be an abort completion point, must be
93 -- made with abort Deferral_Level = 1.
95 -- In general, non-blocking GNARL calls, which may be made from inside
96 -- a protected action, are likely to need to allow nested abort
97 -- deferral.
99 -- With some critical exceptions (which are supposed to be documented),
100 -- internal calls to the tasking runtime system assume abort is already
101 -- deferred, and do not modify the deferral level.
103 -- There is also a set of non-linable defer/undefer routines,
104 -- for direct call from the compiler. These are not in-lineable
105 -- because they may need to be called via pointers ("soft links").
106 -- For the sake of efficiency, the version with Self_ID as parameter
107 -- should used wherever possible. These are all nestable.
109 -- Non-nestable inline versions
111 procedure Defer_Abort (Self_ID : Task_Id);
112 pragma Inline (Defer_Abort);
114 procedure Undefer_Abort (Self_ID : Task_Id);
115 pragma Inline (Undefer_Abort);
117 -- Nestable inline versions
119 procedure Defer_Abort_Nestable (Self_ID : Task_Id);
120 pragma Inline (Defer_Abort_Nestable);
122 procedure Undefer_Abort_Nestable (Self_ID : Task_Id);
123 pragma Inline (Undefer_Abort_Nestable);
125 -- NON-INLINE versions without Self_ID for code generated by the
126 -- expander and for soft links
128 procedure Defer_Abortion;
129 procedure Undefer_Abortion;
131 -- ?????
132 -- Try to phase out all uses of the above versions.
134 procedure Do_Pending_Action (Self_ID : Task_Id);
135 -- Only call with no locks, and when Self_ID.Pending_Action = True
136 -- Perform necessary pending actions (e.g. abortion, priority change).
137 -- This procedure is usually called when needed as a result of
138 -- calling Undefer_Abort, although in the case of e.g. No_Abort
139 -- restriction, it can be necessary to force execution of pending
140 -- actions.
142 function Check_Abort_Status return Integer;
143 -- Returns Boolean'Pos (True) iff abort signal should raise
144 -- Standard.Abort_Signal. Only used by IRIX currently.
146 --------------------------
147 -- Change Base Priority --
148 --------------------------
150 procedure Change_Base_Priority (T : Task_Id);
151 -- Change the base priority of T.
152 -- Has to be called with the affected task's ATCB write-locked.
153 -- May temporariliy release the lock.
155 procedure Poll_Base_Priority_Change (Self_ID : Task_Id);
156 -- Has to be called with Self_ID's ATCB write-locked.
157 -- May temporariliy release the lock.
158 pragma Inline (Poll_Base_Priority_Change);
160 ----------------------
161 -- Task Lock/Unlock --
162 ----------------------
164 procedure Task_Lock (Self_ID : Task_Id);
165 pragma Inline (Task_Lock);
167 procedure Task_Unlock (Self_ID : Task_Id);
168 pragma Inline (Task_Unlock);
169 -- These are versions of Lock_Task and Unlock_Task created for use
170 -- within the GNARL.
172 procedure Final_Task_Unlock (Self_ID : Task_Id);
173 -- This version is only for use in Terminate_Task, when the task
174 -- is relinquishing further rights to its own ATCB.
175 -- There is a very interesting potential race condition there, where
176 -- the old task may run concurrently with a new task that is allocated
177 -- the old tasks (now reused) ATCB. The critical thing here is to
178 -- not make any reference to the ATCB after the lock is released.
179 -- See also comments on Terminate_Task and Unlock.
181 procedure Wakeup_Entry_Caller
182 (Self_ID : Task_Id;
183 Entry_Call : Entry_Call_Link;
184 New_State : Entry_Call_State);
185 pragma Inline (Wakeup_Entry_Caller);
186 -- This is called at the end of service of an entry call,
187 -- to abort the caller if he is in an abortable part, and
188 -- to wake up the caller if he is on Entry_Caller_Sleep.
189 -- Call it holding the lock of Entry_Call.Self.
191 -- Timed_Call or Simple_Call:
192 -- The caller is waiting on Entry_Caller_Sleep, in
193 -- Wait_For_Completion, or Wait_For_Completion_With_Timeout.
195 -- Conditional_Call:
196 -- The caller might be in Wait_For_Completion,
197 -- waiting for a rendezvous (possibly requeued without abort)
198 -- to complete.
200 -- Asynchronous_Call:
201 -- The caller may be executing in the abortable part o
202 -- an async. select, or on a time delay,
203 -- if Entry_Call.State >= Was_Abortable.
205 procedure Locked_Abort_To_Level
206 (Self_ID : Task_Id;
207 T : Task_Id;
208 L : ATC_Level);
209 pragma Inline (Locked_Abort_To_Level);
210 -- Abort a task to a specified ATC level.
211 -- Call this only with T locked.
213 end System.Tasking.Initialization;