annotate gcc/ada/libgnarl/s-tasren.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 . R E N D E Z V O U S --
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 -- Note: the compiler generates direct calls to this interface, via Rtsfind.
kono
parents:
diff changeset
33 -- Any changes to this interface may require corresponding compiler changes.
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 with Ada.Exceptions;
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 with System.Tasking.Protected_Objects.Entries;
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 package System.Tasking.Rendezvous is
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 package STPE renames System.Tasking.Protected_Objects.Entries;
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 procedure Task_Entry_Call
kono
parents:
diff changeset
44 (Acceptor : Task_Id;
kono
parents:
diff changeset
45 E : Task_Entry_Index;
kono
parents:
diff changeset
46 Uninterpreted_Data : System.Address;
kono
parents:
diff changeset
47 Mode : Call_Modes;
kono
parents:
diff changeset
48 Rendezvous_Successful : out Boolean);
kono
parents:
diff changeset
49 -- General entry call used to implement ATC or conditional entry calls.
kono
parents:
diff changeset
50 -- Compiler interface only. Do not call from within the RTS.
kono
parents:
diff changeset
51 -- Acceptor is the ID of the acceptor task.
kono
parents:
diff changeset
52 -- E is the entry index requested.
kono
parents:
diff changeset
53 -- Uninterpreted_Data represents the parameters of the entry. It is
kono
parents:
diff changeset
54 -- constructed by the compiler for the caller and the callee; therefore,
kono
parents:
diff changeset
55 -- the run time never needs to decode this data.
kono
parents:
diff changeset
56 -- Mode can be either Asynchronous_Call (ATC) or Conditional_Call.
kono
parents:
diff changeset
57 -- Rendezvous_Successful is set to True on return if the call was serviced.
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 procedure Timed_Task_Entry_Call
kono
parents:
diff changeset
60 (Acceptor : Task_Id;
kono
parents:
diff changeset
61 E : Task_Entry_Index;
kono
parents:
diff changeset
62 Uninterpreted_Data : System.Address;
kono
parents:
diff changeset
63 Timeout : Duration;
kono
parents:
diff changeset
64 Mode : Delay_Modes;
kono
parents:
diff changeset
65 Rendezvous_Successful : out Boolean);
kono
parents:
diff changeset
66 -- Timed entry call without using ATC.
kono
parents:
diff changeset
67 -- Compiler interface only. Do not call from within the RTS.
kono
parents:
diff changeset
68 -- See Task_Entry_Call for details on Acceptor, E and Uninterpreted_Data.
kono
parents:
diff changeset
69 -- Timeout is the value of the time out.
kono
parents:
diff changeset
70 -- Mode determines whether the delay is relative or absolute.
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 procedure Call_Simple
kono
parents:
diff changeset
73 (Acceptor : Task_Id;
kono
parents:
diff changeset
74 E : Task_Entry_Index;
kono
parents:
diff changeset
75 Uninterpreted_Data : System.Address);
kono
parents:
diff changeset
76 -- Simple entry call.
kono
parents:
diff changeset
77 -- Compiler interface only. Do not call from within the RTS.
kono
parents:
diff changeset
78 --
kono
parents:
diff changeset
79 -- source:
kono
parents:
diff changeset
80 -- T.E1 (Params);
kono
parents:
diff changeset
81 --
kono
parents:
diff changeset
82 -- expansion:
kono
parents:
diff changeset
83 -- declare
kono
parents:
diff changeset
84 -- P : parms := (parm1, parm2, parm3);
kono
parents:
diff changeset
85 -- X : Task_Entry_Index := 1;
kono
parents:
diff changeset
86 -- begin
kono
parents:
diff changeset
87 -- Call_Simple (t._task_id, X, P'Address);
kono
parents:
diff changeset
88 -- parm1 := P.param1;
kono
parents:
diff changeset
89 -- parm2 := P.param2;
kono
parents:
diff changeset
90 -- ...
kono
parents:
diff changeset
91 -- end;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 procedure Cancel_Task_Entry_Call (Cancelled : out Boolean);
kono
parents:
diff changeset
94 -- Cancel pending asynchronous task entry call.
kono
parents:
diff changeset
95 -- Compiler interface only. Do not call from within the RTS.
kono
parents:
diff changeset
96 -- See Exp_Ch9.Expand_N_Asynchronous_Select for code expansion.
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 procedure Requeue_Task_Entry
kono
parents:
diff changeset
99 (Acceptor : Task_Id;
kono
parents:
diff changeset
100 E : Task_Entry_Index;
kono
parents:
diff changeset
101 With_Abort : Boolean);
kono
parents:
diff changeset
102 -- Requeue from a task entry to a task entry.
kono
parents:
diff changeset
103 -- Compiler interface only. Do not call from within the RTS.
kono
parents:
diff changeset
104 -- The code generation for task entry requeues is different from that for
kono
parents:
diff changeset
105 -- protected entry requeues. There is a "goto" that skips around the call
kono
parents:
diff changeset
106 -- to Complete_Rendezvous, so that Requeue_Task_Entry must also do the work
kono
parents:
diff changeset
107 -- of Complete_Rendezvous. The difference is that it does not report that
kono
parents:
diff changeset
108 -- the call's State = Done.
kono
parents:
diff changeset
109 --
kono
parents:
diff changeset
110 -- source:
kono
parents:
diff changeset
111 -- accept e1 do
kono
parents:
diff changeset
112 -- ...A...
kono
parents:
diff changeset
113 -- requeue e2;
kono
parents:
diff changeset
114 -- ...B...
kono
parents:
diff changeset
115 -- end e1;
kono
parents:
diff changeset
116 --
kono
parents:
diff changeset
117 -- expansion:
kono
parents:
diff changeset
118 -- A62b : address;
kono
parents:
diff changeset
119 -- L61b : label
kono
parents:
diff changeset
120 -- begin
kono
parents:
diff changeset
121 -- accept_call (1, A62b);
kono
parents:
diff changeset
122 -- ...A...
kono
parents:
diff changeset
123 -- requeue_task_entry (tTV!(t)._task_id, 2, false);
kono
parents:
diff changeset
124 -- goto L61b;
kono
parents:
diff changeset
125 -- ...B...
kono
parents:
diff changeset
126 -- complete_rendezvous;
kono
parents:
diff changeset
127 -- <<L61b>>
kono
parents:
diff changeset
128 -- exception
kono
parents:
diff changeset
129 -- when others =>
kono
parents:
diff changeset
130 -- exceptional_complete_rendezvous (current_exception);
kono
parents:
diff changeset
131 -- end;
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 procedure Requeue_Protected_To_Task_Entry
kono
parents:
diff changeset
134 (Object : STPE.Protection_Entries_Access;
kono
parents:
diff changeset
135 Acceptor : Task_Id;
kono
parents:
diff changeset
136 E : Task_Entry_Index;
kono
parents:
diff changeset
137 With_Abort : Boolean);
kono
parents:
diff changeset
138 -- Requeue from a protected entry to a task entry.
kono
parents:
diff changeset
139 -- Compiler interface only. Do not call from within the RTS.
kono
parents:
diff changeset
140 --
kono
parents:
diff changeset
141 -- source:
kono
parents:
diff changeset
142 -- entry e2 when b is
kono
parents:
diff changeset
143 -- begin
kono
parents:
diff changeset
144 -- b := false;
kono
parents:
diff changeset
145 -- ...A...
kono
parents:
diff changeset
146 -- requeue t.e2;
kono
parents:
diff changeset
147 -- end e2;
kono
parents:
diff changeset
148 --
kono
parents:
diff changeset
149 -- expansion:
kono
parents:
diff changeset
150 -- procedure rPT__E14b (O : address; P : address; E :
kono
parents:
diff changeset
151 -- protected_entry_index) is
kono
parents:
diff changeset
152 -- type rTVP is access rTV;
kono
parents:
diff changeset
153 -- freeze rTVP []
kono
parents:
diff changeset
154 -- _object : rTVP := rTVP!(O);
kono
parents:
diff changeset
155 -- begin
kono
parents:
diff changeset
156 -- declare
kono
parents:
diff changeset
157 -- rR : protection renames _object._object;
kono
parents:
diff changeset
158 -- vP : integer renames _object.v;
kono
parents:
diff changeset
159 -- bP : boolean renames _object.b;
kono
parents:
diff changeset
160 -- begin
kono
parents:
diff changeset
161 -- b := false;
kono
parents:
diff changeset
162 -- ...A...
kono
parents:
diff changeset
163 -- requeue_protected_to_task_entry (rR'unchecked_access, tTV!(t).
kono
parents:
diff changeset
164 -- _task_id, 2, false);
kono
parents:
diff changeset
165 -- return;
kono
parents:
diff changeset
166 -- end;
kono
parents:
diff changeset
167 -- complete_entry_body (_object._object'unchecked_access, objectF =>
kono
parents:
diff changeset
168 -- 0);
kono
parents:
diff changeset
169 -- return;
kono
parents:
diff changeset
170 -- exception
kono
parents:
diff changeset
171 -- when others =>
kono
parents:
diff changeset
172 -- abort_undefer.all;
kono
parents:
diff changeset
173 -- exceptional_complete_entry_body (_object._object'
kono
parents:
diff changeset
174 -- unchecked_access, current_exception, objectF => 0);
kono
parents:
diff changeset
175 -- return;
kono
parents:
diff changeset
176 -- end rPT__E14b;
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 procedure Selective_Wait
kono
parents:
diff changeset
179 (Open_Accepts : Accept_List_Access;
kono
parents:
diff changeset
180 Select_Mode : Select_Modes;
kono
parents:
diff changeset
181 Uninterpreted_Data : out System.Address;
kono
parents:
diff changeset
182 Index : out Select_Index);
kono
parents:
diff changeset
183 -- Implement select statement.
kono
parents:
diff changeset
184 -- Compiler interface only. Do not call from within the RTS.
kono
parents:
diff changeset
185 -- See comments on Accept_Call.
kono
parents:
diff changeset
186 --
kono
parents:
diff changeset
187 -- source:
kono
parents:
diff changeset
188 -- select accept e1 do
kono
parents:
diff changeset
189 -- ...A...
kono
parents:
diff changeset
190 -- end e1;
kono
parents:
diff changeset
191 -- ...B...
kono
parents:
diff changeset
192 -- or accept e2;
kono
parents:
diff changeset
193 -- ...C...
kono
parents:
diff changeset
194 -- end select;
kono
parents:
diff changeset
195 --
kono
parents:
diff changeset
196 -- expansion:
kono
parents:
diff changeset
197 -- A32b : address;
kono
parents:
diff changeset
198 -- declare
kono
parents:
diff changeset
199 -- A37b : T36b;
kono
parents:
diff changeset
200 -- A37b (1) := (null_body => false, s => 1);
kono
parents:
diff changeset
201 -- A37b (2) := (null_body => true, s => 2);
kono
parents:
diff changeset
202 -- S0 : aliased T36b := accept_list'A37b;
kono
parents:
diff changeset
203 -- J1 : select_index := 0;
kono
parents:
diff changeset
204 -- procedure e1A is
kono
parents:
diff changeset
205 -- begin
kono
parents:
diff changeset
206 -- abort_undefer.all;
kono
parents:
diff changeset
207 -- ...A...
kono
parents:
diff changeset
208 -- <<L31b>>
kono
parents:
diff changeset
209 -- complete_rendezvous;
kono
parents:
diff changeset
210 -- exception
kono
parents:
diff changeset
211 -- when all others =>
kono
parents:
diff changeset
212 -- exceptional_complete_rendezvous (get_gnat_exception);
kono
parents:
diff changeset
213 -- end e1A;
kono
parents:
diff changeset
214 -- begin
kono
parents:
diff changeset
215 -- selective_wait (S0'unchecked_access, simple_mode, A32b, J1);
kono
parents:
diff changeset
216 -- case J1 is
kono
parents:
diff changeset
217 -- when 0 =>
kono
parents:
diff changeset
218 -- goto L3;
kono
parents:
diff changeset
219 -- when 1 =>
kono
parents:
diff changeset
220 -- e1A;
kono
parents:
diff changeset
221 -- goto L1;
kono
parents:
diff changeset
222 -- when 2 =>
kono
parents:
diff changeset
223 -- goto L2;
kono
parents:
diff changeset
224 -- when others =>
kono
parents:
diff changeset
225 -- goto L3;
kono
parents:
diff changeset
226 -- end case;
kono
parents:
diff changeset
227 -- <<L1>>
kono
parents:
diff changeset
228 -- ...B...
kono
parents:
diff changeset
229 -- goto L3;
kono
parents:
diff changeset
230 -- <<L2>>
kono
parents:
diff changeset
231 -- ...C...
kono
parents:
diff changeset
232 -- goto L3;
kono
parents:
diff changeset
233 -- <<L3>>
kono
parents:
diff changeset
234 -- end;
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 procedure Timed_Selective_Wait
kono
parents:
diff changeset
237 (Open_Accepts : Accept_List_Access;
kono
parents:
diff changeset
238 Select_Mode : Select_Modes;
kono
parents:
diff changeset
239 Uninterpreted_Data : out System.Address;
kono
parents:
diff changeset
240 Timeout : Duration;
kono
parents:
diff changeset
241 Mode : Delay_Modes;
kono
parents:
diff changeset
242 Index : out Select_Index);
kono
parents:
diff changeset
243 -- Selective wait with timeout without using ATC.
kono
parents:
diff changeset
244 -- Compiler interface only. Do not call from within the RTS.
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 procedure Accept_Call
kono
parents:
diff changeset
247 (E : Task_Entry_Index;
kono
parents:
diff changeset
248 Uninterpreted_Data : out System.Address);
kono
parents:
diff changeset
249 -- Accept an entry call.
kono
parents:
diff changeset
250 -- Compiler interface only. Do not call from within the RTS.
kono
parents:
diff changeset
251 --
kono
parents:
diff changeset
252 -- source:
kono
parents:
diff changeset
253 -- accept E do ...A... end E;
kono
parents:
diff changeset
254 -- expansion:
kono
parents:
diff changeset
255 -- A27b : address;
kono
parents:
diff changeset
256 -- L26b : label
kono
parents:
diff changeset
257 -- begin
kono
parents:
diff changeset
258 -- accept_call (1, A27b);
kono
parents:
diff changeset
259 -- ...A...
kono
parents:
diff changeset
260 -- complete_rendezvous;
kono
parents:
diff changeset
261 -- <<L26b>>
kono
parents:
diff changeset
262 -- exception
kono
parents:
diff changeset
263 -- when all others =>
kono
parents:
diff changeset
264 -- exceptional_complete_rendezvous (get_gnat_exception);
kono
parents:
diff changeset
265 -- end;
kono
parents:
diff changeset
266 --
kono
parents:
diff changeset
267 -- The handler for Abort_Signal (*all* others) is to handle the case when
kono
parents:
diff changeset
268 -- the acceptor is aborted between Accept_Call and the corresponding
kono
parents:
diff changeset
269 -- Complete_Rendezvous call. We need to wake up the caller in this case.
kono
parents:
diff changeset
270 --
kono
parents:
diff changeset
271 -- See also Selective_Wait
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 procedure Accept_Trivial (E : Task_Entry_Index);
kono
parents:
diff changeset
274 -- Accept an entry call that has no parameters and no body.
kono
parents:
diff changeset
275 -- Compiler interface only. Do not call from within the RTS.
kono
parents:
diff changeset
276 -- This should only be called when there is no accept body, or the accept
kono
parents:
diff changeset
277 -- body is empty.
kono
parents:
diff changeset
278 --
kono
parents:
diff changeset
279 -- source:
kono
parents:
diff changeset
280 -- accept E;
kono
parents:
diff changeset
281 -- expansion:
kono
parents:
diff changeset
282 -- accept_trivial (1);
kono
parents:
diff changeset
283 --
kono
parents:
diff changeset
284 -- The compiler is also able to recognize the following and
kono
parents:
diff changeset
285 -- translate it the same way.
kono
parents:
diff changeset
286 --
kono
parents:
diff changeset
287 -- accept E do null; end E;
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 function Task_Count (E : Task_Entry_Index) return Natural;
kono
parents:
diff changeset
290 -- Return number of tasks waiting on the entry E (of current task)
kono
parents:
diff changeset
291 -- Compiler interface only. Do not call from within the RTS.
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 function Callable (T : Task_Id) return Boolean;
kono
parents:
diff changeset
294 -- Return T'Callable
kono
parents:
diff changeset
295 -- Compiler interface. Do not call from within the RTS, except for body of
kono
parents:
diff changeset
296 -- Ada.Task_Identification.
kono
parents:
diff changeset
297
kono
parents:
diff changeset
298 type Task_Entry_Nesting_Depth is new Task_Entry_Index
kono
parents:
diff changeset
299 range 0 .. Max_Task_Entry;
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 function Task_Entry_Caller (D : Task_Entry_Nesting_Depth) return Task_Id;
kono
parents:
diff changeset
302 -- Return E'Caller. This will only work if called from within an
kono
parents:
diff changeset
303 -- accept statement that is handling E, as required by the LRM (C.7.1(14)).
kono
parents:
diff changeset
304 -- Compiler interface only. Do not call from within the RTS.
kono
parents:
diff changeset
305
kono
parents:
diff changeset
306 procedure Complete_Rendezvous;
kono
parents:
diff changeset
307 -- Called by acceptor to wake up caller
kono
parents:
diff changeset
308
kono
parents:
diff changeset
309 procedure Exceptional_Complete_Rendezvous
kono
parents:
diff changeset
310 (Ex : Ada.Exceptions.Exception_Id);
kono
parents:
diff changeset
311 pragma No_Return (Exceptional_Complete_Rendezvous);
kono
parents:
diff changeset
312 -- Called by acceptor to mark the end of the current rendezvous and
kono
parents:
diff changeset
313 -- propagate an exception to the caller.
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 -- For internal use only:
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 function Task_Do_Or_Queue
kono
parents:
diff changeset
318 (Self_ID : Task_Id;
kono
parents:
diff changeset
319 Entry_Call : Entry_Call_Link) return Boolean;
kono
parents:
diff changeset
320 -- Call this only with abort deferred and holding no locks, except
kono
parents:
diff changeset
321 -- the global RTS lock when Single_Lock is True which must be owned.
kono
parents:
diff changeset
322 -- Returns False iff the call cannot be served or queued, as is the
kono
parents:
diff changeset
323 -- case if the caller is not callable; i.e., a False return value
kono
parents:
diff changeset
324 -- indicates that Tasking_Error should be raised.
kono
parents:
diff changeset
325 -- Either initiate the entry call, such that the accepting task is
kono
parents:
diff changeset
326 -- free to execute the rendezvous, queue the call on the acceptor's
kono
parents:
diff changeset
327 -- queue, or cancel the call. Conditional calls that cannot be
kono
parents:
diff changeset
328 -- accepted immediately are cancelled.
kono
parents:
diff changeset
329
kono
parents:
diff changeset
330 end System.Tasking.Rendezvous;