1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- S Y S T E M . T A S K I N G . R E N D E Z V O U S --
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
27 -- GNARL was developed by the GNARL team at Florida State University. --
28 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
30 ------------------------------------------------------------------------------
32 -- Note: the compiler generates direct calls to this interface, via Rtsfind.
33 -- Any changes to this interface may require corresponding compiler changes.
37 with System
.Tasking
.Protected_Objects
.Entries
;
39 package System
.Tasking
.Rendezvous
is
41 package STPE
renames System
.Tasking
.Protected_Objects
.Entries
;
43 procedure Task_Entry_Call
46 Uninterpreted_Data
: System
.Address
;
48 Rendezvous_Successful
: out Boolean);
49 -- General entry call used to implement ATC or conditional entry calls.
50 -- Compiler interface only. Do not call from within the RTS.
51 -- Acceptor is the ID of the acceptor task.
52 -- E is the entry index requested.
53 -- Uninterpreted_Data represents the parameters of the entry. It is
54 -- constructed by the compiler for the caller and the callee; therefore,
55 -- the run time never needs to decode this data.
56 -- Mode can be either Asynchronous_Call (ATC) or Conditional_Call.
57 -- Rendezvous_Successful is set to True on return if the call was serviced.
59 procedure Timed_Task_Entry_Call
62 Uninterpreted_Data
: System
.Address
;
65 Rendezvous_Successful
: out Boolean);
66 -- Timed entry call without using ATC.
67 -- Compiler interface only. Do not call from within the RTS.
68 -- See Task_Entry_Call for details on Acceptor, E and Uninterpreted_Data.
69 -- Timeout is the value of the time out.
70 -- Mode determines whether the delay is relative or absolute.
75 Uninterpreted_Data
: System
.Address
);
77 -- Compiler interface only. Do not call from within the RTS.
84 -- P : parms := (parm1, parm2, parm3);
85 -- X : Task_Entry_Index := 1;
87 -- Call_Simple (t._task_id, X, P'Address);
93 procedure Cancel_Task_Entry_Call
(Cancelled
: out Boolean);
94 -- Cancel pending asynchronous task entry call.
95 -- Compiler interface only. Do not call from within the RTS.
96 -- See Exp_Ch9.Expand_N_Asynchronous_Select for code expansion.
98 procedure Requeue_Task_Entry
100 E
: Task_Entry_Index
;
101 With_Abort
: Boolean);
102 -- Requeue from a task entry to a task entry.
103 -- Compiler interface only. Do not call from within the RTS.
104 -- The code generation for task entry requeues is different from that for
105 -- protected entry requeues. There is a "goto" that skips around the call
106 -- to Complete_Rendezvous, so that Requeue_Task_Entry must also do the work
107 -- of Complete_Rendezvous. The difference is that it does not report that
108 -- the call's State = Done.
121 -- accept_call (1, A62b);
123 -- requeue_task_entry (tTV!(t)._task_id, 2, false);
126 -- complete_rendezvous;
130 -- exceptional_complete_rendezvous (current_exception);
133 procedure Requeue_Protected_To_Task_Entry
134 (Object
: STPE
.Protection_Entries_Access
;
136 E
: Task_Entry_Index
;
137 With_Abort
: Boolean);
138 -- Requeue from a protected entry to a task entry.
139 -- Compiler interface only. Do not call from within the RTS.
142 -- entry e2 when b is
150 -- procedure rPT__E14b (O : address; P : address; E :
151 -- protected_entry_index) is
152 -- type rTVP is access rTV;
154 -- _object : rTVP := rTVP!(O);
157 -- rR : protection renames _object._object;
158 -- vP : integer renames _object.v;
159 -- bP : boolean renames _object.b;
163 -- requeue_protected_to_task_entry (rR'unchecked_access, tTV!(t).
164 -- _task_id, 2, false);
167 -- complete_entry_body (_object._object'unchecked_access, objectF =>
172 -- abort_undefer.all;
173 -- exceptional_complete_entry_body (_object._object'
174 -- unchecked_access, current_exception, objectF => 0);
178 procedure Selective_Wait
179 (Open_Accepts
: Accept_List_Access
;
180 Select_Mode
: Select_Modes
;
181 Uninterpreted_Data
: out System
.Address
;
182 Index
: out Select_Index
);
183 -- Implement select statement.
184 -- Compiler interface only. Do not call from within the RTS.
185 -- See comments on Accept_Call.
188 -- select accept e1 do
200 -- A37b (1) := (null_body => false, s => 1);
201 -- A37b (2) := (null_body => true, s => 2);
202 -- S0 : aliased T36b := accept_list'A37b;
203 -- J1 : select_index := 0;
206 -- abort_undefer.all;
209 -- complete_rendezvous;
211 -- when all others =>
212 -- exceptional_complete_rendezvous (get_gnat_exception);
215 -- selective_wait (S0'unchecked_access, simple_mode, A32b, J1);
236 procedure Timed_Selective_Wait
237 (Open_Accepts
: Accept_List_Access
;
238 Select_Mode
: Select_Modes
;
239 Uninterpreted_Data
: out System
.Address
;
242 Index
: out Select_Index
);
243 -- Selective wait with timeout without using ATC.
244 -- Compiler interface only. Do not call from within the RTS.
246 procedure Accept_Call
247 (E
: Task_Entry_Index
;
248 Uninterpreted_Data
: out System
.Address
);
249 -- Accept an entry call.
250 -- Compiler interface only. Do not call from within the RTS.
253 -- accept E do ...A... end E;
258 -- accept_call (1, A27b);
260 -- complete_rendezvous;
263 -- when all others =>
264 -- exceptional_complete_rendezvous (get_gnat_exception);
267 -- The handler for Abort_Signal (*all* others) is to handle the case when
268 -- the acceptor is aborted between Accept_Call and the corresponding
269 -- Complete_Rendezvous call. We need to wake up the caller in this case.
271 -- See also Selective_Wait
273 procedure Accept_Trivial
(E
: Task_Entry_Index
);
274 -- Accept an entry call that has no parameters and no body.
275 -- Compiler interface only. Do not call from within the RTS.
276 -- This should only be called when there is no accept body, or the accept
282 -- accept_trivial (1);
284 -- The compiler is also able to recognize the following and
285 -- translate it the same way.
287 -- accept E do null; end E;
289 function Task_Count
(E
: Task_Entry_Index
) return Natural;
290 -- Return number of tasks waiting on the entry E (of current task)
291 -- Compiler interface only. Do not call from within the RTS.
293 function Callable
(T
: Task_Id
) return Boolean;
295 -- Compiler interface. Do not call from within the RTS, except for body of
296 -- Ada.Task_Identification.
298 type Task_Entry_Nesting_Depth
is new Task_Entry_Index
299 range 0 .. Max_Task_Entry
;
301 function Task_Entry_Caller
(D
: Task_Entry_Nesting_Depth
) return Task_Id
;
302 -- Return E'Caller. This will only work if called from within an
303 -- accept statement that is handling E, as required by the LRM (C.7.1(14)).
304 -- Compiler interface only. Do not call from within the RTS.
306 procedure Complete_Rendezvous
;
307 -- Called by acceptor to wake up caller
309 procedure Exceptional_Complete_Rendezvous
310 (Ex
: Ada
.Exceptions
.Exception_Id
);
311 pragma No_Return
(Exceptional_Complete_Rendezvous
);
312 -- Called by acceptor to mark the end of the current rendezvous and
313 -- propagate an exception to the caller.
315 -- For internal use only:
317 function Task_Do_Or_Queue
319 Entry_Call
: Entry_Call_Link
) return Boolean;
320 -- Call this only with abort deferred and holding no locks, except
321 -- the global RTS lock when Single_Lock is True which must be owned.
322 -- Returns False iff the call cannot be served or queued, as is the
323 -- case if the caller is not callable; i.e., a False return value
324 -- indicates that Tasking_Error should be raised.
325 -- Either initiate the entry call, such that the accepting task is
326 -- free to execute the rendezvous, queue the call on the acceptor's
327 -- queue, or cancel the call. Conditional calls that cannot be
328 -- accepted immediately are cancelled.
330 end System
.Tasking
.Rendezvous
;