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-2007, 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 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
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. --
29 -- GNARL was developed by the GNARL team at Florida State University. --
30 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
32 ------------------------------------------------------------------------------
34 -- Note: the compiler generates direct calls to this interface, via Rtsfind.
35 -- Any changes to this interface may require corresponding compiler changes.
38 -- Used for, Exception_Id
40 with System
.Tasking
.Protected_Objects
.Entries
;
41 -- used for Protection_Entries
43 package System
.Tasking
.Rendezvous
is
45 package STPE
renames System
.Tasking
.Protected_Objects
.Entries
;
47 procedure Task_Entry_Call
50 Uninterpreted_Data
: System
.Address
;
52 Rendezvous_Successful
: out Boolean);
53 -- General entry call used to implement ATC or conditional entry calls.
54 -- Compiler interface only. Do not call from within the RTS.
55 -- Acceptor is the ID of the acceptor task.
56 -- E is the entry index requested.
57 -- Uninterpreted_Data represents the parameters of the entry. It is
58 -- constructed by the compiler for the caller and the callee; therefore,
59 -- the run time never needs to decode this data.
60 -- Mode can be either Asynchronous_Call (ATC) or Conditional_Call.
61 -- Rendezvous_Successful is set to True on return if the call was serviced.
63 procedure Timed_Task_Entry_Call
66 Uninterpreted_Data
: System
.Address
;
69 Rendezvous_Successful
: out Boolean);
70 -- Timed entry call without using ATC.
71 -- Compiler interface only. Do not call from within the RTS.
72 -- See Task_Entry_Call for details on Acceptor, E and Uninterpreted_Data.
73 -- Timeout is the value of the time out.
74 -- Mode determines whether the delay is relative or absolute.
79 Uninterpreted_Data
: System
.Address
);
81 -- Compiler interface only. Do not call from within the RTS.
88 -- P : parms := (parm1, parm2, parm3);
89 -- X : Task_Entry_Index := 1;
91 -- Call_Simple (t._task_id, X, P'Address);
97 procedure Cancel_Task_Entry_Call
(Cancelled
: out Boolean);
98 -- Cancel pending asynchronous task entry call.
99 -- Compiler interface only. Do not call from within the RTS.
100 -- See Exp_Ch9.Expand_N_Asynchronous_Select for code expansion.
102 procedure Requeue_Task_Entry
104 E
: Task_Entry_Index
;
105 With_Abort
: Boolean);
106 -- Requeue from a task entry to a task entry.
107 -- Compiler interface only. Do not call from within the RTS.
108 -- The code generation for task entry requeues is different from that for
109 -- protected entry requeues. There is a "goto" that skips around the call
110 -- to Complete_Rendezvous, so that Requeue_Task_Entry must also do the work
111 -- of Complete_Rendezvous. The difference is that it does not report that
112 -- the call's State = Done.
125 -- accept_call (1, A62b);
127 -- requeue_task_entry (tTV!(t)._task_id, 2, false);
130 -- complete_rendezvous;
134 -- exceptional_complete_rendezvous (current_exception);
137 procedure Requeue_Protected_To_Task_Entry
138 (Object
: STPE
.Protection_Entries_Access
;
140 E
: Task_Entry_Index
;
141 With_Abort
: Boolean);
142 -- Requeue from a protected entry to a task entry.
143 -- Compiler interface only. Do not call from within the RTS.
146 -- entry e2 when b is
154 -- procedure rPT__E14b (O : address; P : address; E :
155 -- protected_entry_index) is
156 -- type rTVP is access rTV;
158 -- _object : rTVP := rTVP!(O);
161 -- rR : protection renames _object._object;
162 -- vP : integer renames _object.v;
163 -- bP : boolean renames _object.b;
167 -- requeue_protected_to_task_entry (rR'unchecked_access, tTV!(t).
168 -- _task_id, 2, false);
171 -- complete_entry_body (_object._object'unchecked_access, objectF =>
176 -- abort_undefer.all;
177 -- exceptional_complete_entry_body (_object._object'
178 -- unchecked_access, current_exception, objectF => 0);
182 procedure Selective_Wait
183 (Open_Accepts
: Accept_List_Access
;
184 Select_Mode
: Select_Modes
;
185 Uninterpreted_Data
: out System
.Address
;
186 Index
: out Select_Index
);
187 -- Implement select statement.
188 -- Compiler interface only. Do not call from within the RTS.
189 -- See comments on Accept_Call.
192 -- select accept e1 do
204 -- A37b (1) := (null_body => false, s => 1);
205 -- A37b (2) := (null_body => true, s => 2);
206 -- S0 : aliased T36b := accept_list'A37b;
207 -- J1 : select_index := 0;
210 -- abort_undefer.all;
213 -- complete_rendezvous;
215 -- when all others =>
216 -- exceptional_complete_rendezvous (get_gnat_exception);
219 -- selective_wait (S0'unchecked_access, simple_mode, A32b, J1);
240 procedure Timed_Selective_Wait
241 (Open_Accepts
: Accept_List_Access
;
242 Select_Mode
: Select_Modes
;
243 Uninterpreted_Data
: out System
.Address
;
246 Index
: out Select_Index
);
247 -- Selective wait with timeout without using ATC.
248 -- Compiler interface only. Do not call from within the RTS.
250 procedure Accept_Call
251 (E
: Task_Entry_Index
;
252 Uninterpreted_Data
: out System
.Address
);
253 -- Accept an entry call.
254 -- Compiler interface only. Do not call from within the RTS.
257 -- accept E do ...A... end E;
262 -- accept_call (1, A27b);
264 -- complete_rendezvous;
267 -- when all others =>
268 -- exceptional_complete_rendezvous (get_gnat_exception);
271 -- The handler for Abort_Signal (*all* others) is to handle the case when
272 -- the acceptor is aborted between Accept_Call and the corresponding
273 -- Complete_Rendezvous call. We need to wake up the caller in this case.
275 -- See also Selective_Wait
277 procedure Accept_Trivial
(E
: Task_Entry_Index
);
278 -- Accept an entry call that has no parameters and no body.
279 -- Compiler interface only. Do not call from within the RTS.
280 -- This should only be called when there is no accept body, or the accept
286 -- accept_trivial (1);
288 -- The compiler is also able to recognize the following and
289 -- translate it the same way.
291 -- accept E do null; end E;
293 function Task_Count
(E
: Task_Entry_Index
) return Natural;
294 -- Return number of tasks waiting on the entry E (of current task)
295 -- Compiler interface only. Do not call from within the RTS.
297 function Callable
(T
: Task_Id
) return Boolean;
299 -- Compiler interface. Do not call from within the RTS, except for body of
300 -- Ada.Task_Identification.
302 type Task_Entry_Nesting_Depth
is new Task_Entry_Index
303 range 0 .. Max_Task_Entry
;
305 function Task_Entry_Caller
(D
: Task_Entry_Nesting_Depth
) return Task_Id
;
306 -- Return E'Caller. This will only work if called from within an
307 -- accept statement that is handling E, as required by the LRM (C.7.1(14)).
308 -- Compiler interface only. Do not call from within the RTS.
310 procedure Complete_Rendezvous
;
311 -- Called by acceptor to wake up caller
313 procedure Exceptional_Complete_Rendezvous
314 (Ex
: Ada
.Exceptions
.Exception_Id
);
315 -- Called by acceptor to mark the end of the current rendezvous and
316 -- propagate an exception to the caller.
318 -- For internal use only:
320 function Task_Do_Or_Queue
322 Entry_Call
: Entry_Call_Link
) return Boolean;
323 -- Call this only with abort deferred and holding no locks, except
324 -- the global RTS lock when Single_Lock is True which must be owned.
325 -- Returns False iff the call cannot be served or queued, as is the
326 -- case if the caller is not callable; i.e., a False return value
327 -- indicates that Tasking_Error should be raised.
328 -- Either initiate the entry call, such that the accepting task is
329 -- free to execute the rendezvous, queue the call on the acceptor's
330 -- queue, or cancel the call. Conditional calls that cannot be
331 -- accepted immediately are cancelled.
333 end System
.Tasking
.Rendezvous
;