annotate gcc/ada/libgnarl/s-tasini.ads @ 131:84e7813d76e9

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