1 ------------------------------------------------------------------------------
3 -- GNU ADA 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 --
11 -- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
13 -- GNARL is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNARL; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
31 -- GNARL was developed by the GNARL team at Florida State University. It is --
32 -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). --
34 ------------------------------------------------------------------------------
36 -- Note: the compiler generates direct calls to this interface, via Rtsfind.
37 -- Any changes to this interface may require corresponding compiler changes.
40 -- Used for, Exception_Id
42 with System.Tasking.Protected_Objects.Entries;
43 -- used for Protection_Entries
45 package System.Tasking.Rendezvous is
47 package STPE renames System.Tasking.Protected_Objects.Entries;
49 procedure Task_Entry_Call
52 Uninterpreted_Data : System.Address;
54 Rendezvous_Successful : out Boolean);
55 -- General entry call used to implement ATC or conditional entry calls.
56 -- Compiler interface only. Do not call from within the RTS.
57 -- Acceptor is the ID of the acceptor task.
58 -- E is the entry index requested.
59 -- Uninterpreted_Data represents the parameters of the entry. It is
60 -- constructed by the compiler for the caller and the callee; therefore,
61 -- the run time never needs to decode this data.
62 -- Mode can be either Asynchronous_Call (ATC) or Conditional_Call.
63 -- Rendezvous_Successful is set to True on return if the call was serviced.
65 procedure Timed_Task_Entry_Call
68 Uninterpreted_Data : System.Address;
71 Rendezvous_Successful : out Boolean);
72 -- Timed entry call without using ATC.
73 -- Compiler interface only. Do not call from within the RTS.
74 -- See Task_Entry_Call for details on Acceptor, E and Uninterpreted_Data.
75 -- Timeout is the value of the time out.
76 -- Mode determines whether the delay is relative or absolute.
81 Uninterpreted_Data : System.Address);
83 -- Compiler interface only. Do not call from within the RTS.
90 -- P : parms := (parm1, parm2, parm3);
91 -- X : Task_Entry_Index := 1;
93 -- Call_Simple (t._task_id, X, P'Address);
99 procedure Cancel_Task_Entry_Call (Cancelled : out Boolean);
100 -- Cancel pending asynchronous task entry call.
101 -- Compiler interface only. Do not call from within the RTS.
102 -- See Exp_Ch9.Expand_N_Asynchronous_Select for code expansion.
104 procedure Requeue_Task_Entry
106 E : Task_Entry_Index;
107 With_Abort : Boolean);
108 -- Requeue from a task entry to a task entry.
109 -- Compiler interface only. Do not call from within the RTS.
110 -- The code generation for task entry requeues is different from that for
111 -- protected entry requeues. There is a "goto" that skips around the call
112 -- to Complete_Rendezvous, so that Requeue_Task_Entry must also do the work
113 -- of Complete_Rendezvous. The difference is that it does not report that
114 -- the call's State = Done.
127 -- accept_call (1, A62b);
129 -- requeue_task_entry (tTV!(t)._task_id, 2, false);
132 -- complete_rendezvous;
136 -- exceptional_complete_rendezvous (current_exception);
139 procedure Requeue_Protected_To_Task_Entry
140 (Object : STPE.Protection_Entries_Access;
142 E : Task_Entry_Index;
143 With_Abort : Boolean);
144 -- Requeue from a protected entry to a task entry.
145 -- Compiler interface only. Do not call from within the RTS.
148 -- entry e2 when b is
156 -- procedure rPT__E14b (O : address; P : address; E :
157 -- protected_entry_index) is
158 -- type rTVP is access rTV;
160 -- _object : rTVP := rTVP!(O);
163 -- rR : protection renames _object._object;
164 -- vP : integer renames _object.v;
165 -- bP : boolean renames _object.b;
169 -- requeue_protected_to_task_entry (rR'unchecked_access, tTV!(t).
170 -- _task_id, 2, false);
173 -- complete_entry_body (_object._object'unchecked_access, objectF =>
178 -- abort_undefer.all;
179 -- exceptional_complete_entry_body (_object._object'
180 -- unchecked_access, current_exception, objectF => 0);
184 procedure Selective_Wait
185 (Open_Accepts : Accept_List_Access;
186 Select_Mode : Select_Modes;
187 Uninterpreted_Data : out System.Address;
188 Index : out Select_Index);
189 -- Implement select statement.
190 -- Compiler interface only. Do not call from within the RTS.
191 -- See comments on Accept_Call.
194 -- select accept e1 do
206 -- A37b (1) := (null_body => false, s => 1);
207 -- A37b (2) := (null_body => true, s => 2);
208 -- S0 : aliased T36b := accept_list'A37b;
209 -- J1 : select_index := 0;
212 -- abort_undefer.all;
215 -- complete_rendezvous;
217 -- when all others =>
218 -- exceptional_complete_rendezvous (get_gnat_exception);
221 -- selective_wait (S0'unchecked_access, simple_mode, A32b, J1);
242 procedure Timed_Selective_Wait
243 (Open_Accepts : Accept_List_Access;
244 Select_Mode : Select_Modes;
245 Uninterpreted_Data : out System.Address;
248 Index : out Select_Index);
249 -- Selective wait with timeout without using ATC.
250 -- Compiler interface only. Do not call from within the RTS.
252 procedure Accept_Call
253 (E : Task_Entry_Index;
254 Uninterpreted_Data : out System.Address);
255 -- Accept an entry call.
256 -- Compiler interface only. Do not call from within the RTS.
259 -- accept E do ...A... end E;
264 -- accept_call (1, A27b);
266 -- complete_rendezvous;
269 -- when all others =>
270 -- exceptional_complete_rendezvous (get_gnat_exception);
273 -- The handler for Abort_Signal (*all* others) is to handle the case when
274 -- the acceptor is aborted between Accept_Call and the corresponding
275 -- Complete_Rendezvous call. We need to wake up the caller in this case.
277 -- See also Selective_Wait
279 procedure Accept_Trivial (E : Task_Entry_Index);
280 -- Accept an entry call that has no parameters and no body.
281 -- Compiler interface only. Do not call from within the RTS.
282 -- This should only be called when there is no accept body, or the accept
288 -- accept_trivial (1);
290 -- The compiler is also able to recognize the following and
291 -- translate it the same way.
293 -- accept E do null; end E;
295 function Task_Count (E : Task_Entry_Index) return Natural;
296 -- Return number of tasks waiting on the entry E (of current task)
297 -- Compiler interface only. Do not call from within the RTS.
299 function Callable (T : Task_ID) return Boolean;
301 -- Compiler interface. Do not call from within the RTS, except for body of
302 -- Ada.Task_Identification.
304 type Task_Entry_Nesting_Depth is new Task_Entry_Index
305 range 0 .. Max_Task_Entry;
307 function Task_Entry_Caller (D : Task_Entry_Nesting_Depth) return Task_ID;
308 -- Return E'Caller. This will only work if called from within an
309 -- accept statement that is handling E, as required by the LRM (C.7.1(14)).
310 -- Compiler interface only. Do not call from within the RTS.
312 procedure Complete_Rendezvous;
313 -- Called by acceptor to wake up caller
315 procedure Exceptional_Complete_Rendezvous
316 (Ex : Ada.Exceptions.Exception_Id);
317 -- Called by acceptor to mark the end of the current rendezvous and
318 -- propagate an exception to the caller.
320 -- For internal use only:
322 function Task_Do_Or_Queue
324 Entry_Call : Entry_Call_Link;
325 With_Abort : Boolean) return Boolean;
326 -- Call this only with abort deferred and holding no locks, except
327 -- the global RTS lock when Single_Lock is True which must be owned.
328 -- Returns False iff the call cannot be served or queued, as is the
329 -- case if the caller is not callable; i.e., a False return value
330 -- indicates that Tasking_Error should be raised.
331 -- Either initiate the entry call, such that the accepting task is
332 -- free to execute the rendezvous, queue the call on the acceptor's
333 -- queue, or cancel the call. Conditional calls that cannot be
334 -- accepted immediately are cancelled.
336 end System.Tasking.Rendezvous;