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 ------------------------------------------------------------------------------
37 -- Used for Exception_ID
42 with System.Task_Primitives.Operations;
43 -- used for Get_Priority
51 with System.Tasking.Entry_Calls;
52 -- Used for Wait_For_Completion
53 -- Wait_For_Completion_With_Timeout
54 -- Wait_Until_Abortable
56 with System.Tasking.Initialization;
57 -- used for Defer_Abort
59 -- Poll_Base_Priority_Change
61 with System.Tasking.Queuing;
64 -- Select_Task_Entry_Call
67 with System.Tasking.Utilities;
68 -- used for Check_Exception
70 -- Wakeup_Entry_Caller
72 with System.Tasking.Protected_Objects.Operations;
73 -- used for PO_Do_Or_Queue
78 with System.Tasking.Debug;
81 with System.Parameters;
82 -- used for Single_Lock
85 with System.Traces.Tasking;
86 -- used for Send_Trace_Info
88 package body System.Tasking.Rendezvous is
90 package STPO renames System.Task_Primitives.Operations;
91 package POO renames Protected_Objects.Operations;
92 package POE renames Protected_Objects.Entries;
95 use Task_Primitives.Operations;
97 use System.Traces.Tasking;
99 type Select_Treatment is (
100 Accept_Alternative_Selected, -- alternative with non-null body
101 Accept_Alternative_Completed, -- alternative with null body
104 Accept_Alternative_Open,
105 No_Alternative_Open);
107 Default_Treatment : constant array (Select_Modes) of Select_Treatment :=
108 (Simple_Mode => No_Alternative_Open,
109 Else_Mode => Else_Selected,
110 Terminate_Mode => Terminate_Selected,
111 Delay_Mode => No_Alternative_Open);
113 New_State : constant array (Boolean, Entry_Call_State)
114 of Entry_Call_State :=
116 (Never_Abortable => Never_Abortable,
117 Not_Yet_Abortable => Now_Abortable,
118 Was_Abortable => Now_Abortable,
119 Now_Abortable => Now_Abortable,
121 Cancelled => Cancelled),
123 (Never_Abortable => Never_Abortable,
124 Not_Yet_Abortable => Not_Yet_Abortable,
125 Was_Abortable => Was_Abortable,
126 Now_Abortable => Now_Abortable,
128 Cancelled => Cancelled)
131 -----------------------
132 -- Local Subprograms --
133 -----------------------
135 procedure Local_Defer_Abort (Self_Id : Task_ID) renames
136 System.Tasking.Initialization.Defer_Abort_Nestable;
138 procedure Local_Undefer_Abort (Self_Id : Task_ID) renames
139 System.Tasking.Initialization.Undefer_Abort_Nestable;
141 -- Florist defers abort around critical sections that
142 -- make entry calls to the Interrupt_Manager task, which
143 -- violates the general rule about top-level runtime system
144 -- calls from abort-deferred regions. It is not that this is
145 -- unsafe, but when it occurs in "normal" programs it usually
146 -- means either the user is trying to do a potentially blocking
147 -- operation from within a protected object, or there is a
148 -- runtime system/compiler error that has failed to undefer
149 -- an earlier abort deferral. Thus, for debugging it may be
150 -- wise to modify the above renamings to the non-nestable forms.
152 procedure Boost_Priority (Call : Entry_Call_Link; Acceptor : Task_ID);
153 pragma Inline (Boost_Priority);
154 -- Call this only with abort deferred and holding lock of Acceptor.
156 procedure Call_Synchronous
158 E : Task_Entry_Index;
159 Uninterpreted_Data : System.Address;
161 Rendezvous_Successful : out Boolean);
162 pragma Inline (Call_Synchronous);
163 -- This call is used to make a simple or conditional entry call.
165 procedure Setup_For_Rendezvous_With_Body
166 (Entry_Call : Entry_Call_Link;
168 pragma Inline (Setup_For_Rendezvous_With_Body);
169 -- Call this only with abort deferred and holding lock of Acceptor.
170 -- When a rendezvous selected (ready for rendezvous) we need to save
171 -- privious caller and adjust the priority. Also we need to make
172 -- this call not Abortable (Cancellable) since the rendezvous has
173 -- already been started.
175 function Is_Entry_Open (T : Task_ID; E : Task_Entry_Index) return Boolean;
176 pragma Inline (Is_Entry_Open);
177 -- Call this only with abort deferred and holding lock of T.
179 procedure Wait_For_Call (Self_Id : Task_ID);
180 pragma Inline (Wait_For_Call);
181 -- Call this only with abort deferred and holding lock of Self_Id.
182 -- An accepting task goes into Sleep by calling this routine
183 -- waiting for a call from the caller or waiting for an abort.
184 -- Make sure Self_Id is locked before calling this routine.
190 procedure Accept_Call
191 (E : Task_Entry_Index;
192 Uninterpreted_Data : out System.Address)
194 Self_Id : constant Task_ID := STPO.Self;
195 Caller : Task_ID := null;
196 Open_Accepts : aliased Accept_List (1 .. 1);
197 Entry_Call : Entry_Call_Link;
200 Initialization.Defer_Abort (Self_Id);
206 STPO.Write_Lock (Self_Id);
208 if not Self_Id.Callable then
209 pragma Assert (Self_Id.Pending_ATC_Level = 0);
211 pragma Assert (Self_Id.Pending_Action);
213 STPO.Unlock (Self_Id);
219 Initialization.Undefer_Abort (Self_Id);
221 -- Should never get here ???
223 pragma Assert (False);
224 raise Standard'Abort_Signal;
227 Queuing.Dequeue_Head (Self_Id.Entry_Queues (E), Entry_Call);
229 if Entry_Call /= null then
230 Caller := Entry_Call.Self;
231 Setup_For_Rendezvous_With_Body (Entry_Call, Self_Id);
232 Uninterpreted_Data := Entry_Call.Uninterpreted_Data;
237 Open_Accepts (1).Null_Body := False;
238 Open_Accepts (1).S := E;
239 Self_Id.Open_Accepts := Open_Accepts'Unrestricted_Access;
241 -- Wait for normal call
243 if Parameters.Runtime_Traces then
244 Send_Trace_Info (W_Accept, Self_Id, Integer (Open_Accepts'Length));
248 (Debug.Trace (Self_Id, "Accept_Call: wait", 'R'));
249 Wait_For_Call (Self_Id);
251 pragma Assert (Self_Id.Open_Accepts = null);
253 if Self_Id.Common.Call /= null then
254 Caller := Self_Id.Common.Call.Self;
255 Uninterpreted_Data :=
256 Caller.Entry_Calls (Caller.ATC_Nesting_Level).Uninterpreted_Data;
258 -- Case of an aborted task.
260 Uninterpreted_Data := System.Null_Address;
264 -- Self_Id.Common.Call should already be updated by the Caller
265 -- On return, we will start the rendezvous.
267 STPO.Unlock (Self_Id);
273 Initialization.Undefer_Abort (Self_Id);
275 if Parameters.Runtime_Traces then
276 Send_Trace_Info (M_Accept_Complete, Caller, Entry_Index (E));
284 procedure Accept_Trivial (E : Task_Entry_Index) is
285 Self_Id : constant Task_ID := STPO.Self;
286 Caller : Task_ID := null;
287 Open_Accepts : aliased Accept_List (1 .. 1);
288 Entry_Call : Entry_Call_Link;
291 Initialization.Defer_Abort_Nestable (Self_Id);
297 STPO.Write_Lock (Self_Id);
299 if not Self_Id.Callable then
300 pragma Assert (Self_Id.Pending_ATC_Level = 0);
302 pragma Assert (Self_Id.Pending_Action);
304 STPO.Unlock (Self_Id);
310 Initialization.Undefer_Abort_Nestable (Self_Id);
312 -- Should never get here ???
314 pragma Assert (False);
315 raise Standard'Abort_Signal;
318 Queuing.Dequeue_Head (Self_Id.Entry_Queues (E), Entry_Call);
320 if Entry_Call = null then
321 -- Need to wait for entry call
323 Open_Accepts (1).Null_Body := True;
324 Open_Accepts (1).S := E;
325 Self_Id.Open_Accepts := Open_Accepts'Unrestricted_Access;
327 if Parameters.Runtime_Traces then
328 Send_Trace_Info (W_Accept, Self_Id, Integer (Open_Accepts'Length));
332 (Debug.Trace (Self_Id, "Accept_Trivial: wait", 'R'));
334 Wait_For_Call (Self_Id);
336 pragma Assert (Self_Id.Open_Accepts = null);
338 -- No need to do anything special here for pending abort.
339 -- Abort_Signal will be raised by Undefer on exit.
341 STPO.Unlock (Self_Id);
343 else -- found caller already waiting
344 pragma Assert (Entry_Call.State < Done);
346 STPO.Unlock (Self_Id);
347 Caller := Entry_Call.Self;
349 STPO.Write_Lock (Caller);
350 Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done);
351 STPO.Unlock (Caller);
354 if Parameters.Runtime_Traces then
355 Send_Trace_Info (M_Accept_Complete);
357 -- Fake one, since there is (???) no way
358 -- to know that the rendezvous is over
360 Send_Trace_Info (M_RDV_Complete);
367 Initialization.Undefer_Abort_Nestable (Self_Id);
374 procedure Boost_Priority (Call : Entry_Call_Link; Acceptor : Task_ID) is
375 Caller : constant Task_ID := Call.Self;
376 Caller_Prio : System.Any_Priority := Get_Priority (Caller);
377 Acceptor_Prio : System.Any_Priority := Get_Priority (Acceptor);
380 if Caller_Prio > Acceptor_Prio then
381 Call.Acceptor_Prev_Priority := Acceptor_Prio;
382 Set_Priority (Acceptor, Caller_Prio);
385 Call.Acceptor_Prev_Priority := Priority_Not_Boosted;
393 procedure Call_Simple
395 E : Task_Entry_Index;
396 Uninterpreted_Data : System.Address)
398 Rendezvous_Successful : Boolean;
401 (Acceptor, E, Uninterpreted_Data, Simple_Call, Rendezvous_Successful);
404 ----------------------
405 -- Call_Synchronous --
406 ----------------------
408 -- Called from Call_Simple and Task_Entry_Call.
410 procedure Call_Synchronous
412 E : Task_Entry_Index;
413 Uninterpreted_Data : System.Address;
415 Rendezvous_Successful : out Boolean)
417 Self_Id : constant Task_ID := STPO.Self;
419 Entry_Call : Entry_Call_Link;
422 pragma Assert (Mode /= Asynchronous_Call);
424 Local_Defer_Abort (Self_Id);
425 Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level + 1;
427 (Debug.Trace (Self_Id, "CS: entered ATC level: " &
428 ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A'));
429 Level := Self_Id.ATC_Nesting_Level;
430 Entry_Call := Self_Id.Entry_Calls (Level)'Access;
431 Entry_Call.Next := null;
432 Entry_Call.Mode := Mode;
433 Entry_Call.Cancellation_Attempted := False;
435 if Parameters.Runtime_Traces then
436 Send_Trace_Info (W_Call, Acceptor, Entry_Index (E));
439 -- If this is a call made inside of an abort deferred region,
440 -- the call should be never abortable.
442 if Self_Id.Deferral_Level > 1 then
443 Entry_Call.State := Never_Abortable;
445 Entry_Call.State := Now_Abortable;
448 Entry_Call.E := Entry_Index (E);
449 Entry_Call.Prio := Get_Priority (Self_Id);
450 Entry_Call.Uninterpreted_Data := Uninterpreted_Data;
451 Entry_Call.Called_Task := Acceptor;
452 Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id;
454 -- Note: the caller will undefer abort on return (see WARNING above)
460 if not Task_Do_Or_Queue
461 (Self_Id, Entry_Call, With_Abort => True)
463 Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level - 1;
469 if Parameters.Runtime_Traces then
470 Send_Trace_Info (E_Missed, Acceptor);
473 Initialization.Undefer_Abort (Self_Id);
475 (Debug.Trace (Self_Id, "CS: exited to ATC level: " &
476 ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A'));
480 STPO.Write_Lock (Self_Id);
482 (Debug.Trace (Self_Id, "Call_Synchronous: wait", 'R'));
483 Entry_Calls.Wait_For_Completion (Entry_Call);
485 (Debug.Trace (Self_Id, "Call_Synchronous: done waiting", 'R'));
486 Rendezvous_Successful := Entry_Call.State = Done;
487 STPO.Unlock (Self_Id);
493 Local_Undefer_Abort (Self_Id);
494 Entry_Calls.Check_Exception (Self_Id, Entry_Call);
495 end Call_Synchronous;
501 function Callable (T : Task_ID) return Boolean is
503 Self_Id : constant Task_ID := STPO.Self;
506 Initialization.Defer_Abort (Self_Id);
513 Result := T.Callable;
520 Initialization.Undefer_Abort (Self_Id);
524 ----------------------------
525 -- Cancel_Task_Entry_Call --
526 ----------------------------
528 procedure Cancel_Task_Entry_Call (Cancelled : out Boolean) is
530 Entry_Calls.Try_To_Cancel_Entry_Call (Cancelled);
531 end Cancel_Task_Entry_Call;
533 -------------------------
534 -- Complete_Rendezvous --
535 -------------------------
537 procedure Complete_Rendezvous is
539 Exceptional_Complete_Rendezvous (Ada.Exceptions.Null_Id);
540 end Complete_Rendezvous;
542 -------------------------------------
543 -- Exceptional_Complete_Rendezvous --
544 -------------------------------------
546 procedure Exceptional_Complete_Rendezvous
547 (Ex : Ada.Exceptions.Exception_Id)
549 Self_Id : constant Task_ID := STPO.Self;
550 Entry_Call : Entry_Call_Link := Self_Id.Common.Call;
552 Called_PO : STPE.Protection_Entries_Access;
554 Exception_To_Raise : Ada.Exceptions.Exception_Id := Ex;
555 Ceiling_Violation : Boolean;
557 use type Ada.Exceptions.Exception_Id;
558 procedure Internal_Reraise;
559 pragma Import (C, Internal_Reraise, "__gnat_reraise");
561 use type STPE.Protection_Entries_Access;
564 -- Consider phasing out Complete_Rendezvous in favor
565 -- of direct call to this with Ada.Exceptions.Null_ID.
566 -- See code expansion examples for Accept_Call and Selective_Wait.
567 -- Also consider putting an explicit re-raise after this call, in
568 -- the generated code. That way we could eliminate the
569 -- code here that reraises the exception.
571 -- The deferral level is critical here,
572 -- since we want to raise an exception or allow abort to take
573 -- place, if there is an exception or abort pending.
576 (Debug.Trace (Self_Id, "Exceptional_Complete_Rendezvous", 'R'));
578 if Ex = Ada.Exceptions.Null_Id then
579 -- The call came from normal end-of-rendezvous,
580 -- so abort is not yet deferred.
582 if Parameters.Runtime_Traces then
583 Send_Trace_Info (M_RDV_Complete, Entry_Call.Self);
586 Initialization.Defer_Abort_Nestable (Self_Id);
589 -- We need to clean up any accepts which Self may have
590 -- been serving when it was aborted.
592 if Ex = Standard'Abort_Signal'Identity then
597 while Entry_Call /= null loop
598 Entry_Call.Exception_To_Raise := Tasking_Error'Identity;
600 -- All forms of accept make sure that the acceptor is not
601 -- completed, before accepting further calls, so that we
602 -- can be sure that no further calls are made after the
603 -- current calls are purged.
605 Caller := Entry_Call.Self;
607 -- Take write lock. This follows the lock precedence rule that
608 -- Caller may be locked while holding lock of Acceptor.
609 -- Complete the call abnormally, with exception.
611 STPO.Write_Lock (Caller);
612 Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done);
613 STPO.Unlock (Caller);
614 Entry_Call := Entry_Call.Acceptor_Prev_Call;
622 Caller := Entry_Call.Self;
624 if Entry_Call.Needs_Requeue then
625 -- We dare not lock Self_Id at the same time as Caller,
626 -- for fear of deadlock.
628 Entry_Call.Needs_Requeue := False;
629 Self_Id.Common.Call := Entry_Call.Acceptor_Prev_Call;
631 if Entry_Call.Called_Task /= null then
632 -- Requeue to another task entry
638 if not Task_Do_Or_Queue
639 (Self_Id, Entry_Call, Entry_Call.Requeue_With_Abort)
645 Initialization.Undefer_Abort (Self_Id);
654 -- Requeue to a protected entry
656 Called_PO := POE.To_Protection (Entry_Call.Called_PO);
657 STPE.Lock_Entries (Called_PO, Ceiling_Violation);
659 if Ceiling_Violation then
660 pragma Assert (Ex = Ada.Exceptions.Null_Id);
662 Exception_To_Raise := Program_Error'Identity;
663 Entry_Call.Exception_To_Raise := Exception_To_Raise;
669 STPO.Write_Lock (Caller);
670 Initialization.Wakeup_Entry_Caller
671 (Self_Id, Entry_Call, Done);
672 STPO.Unlock (Caller);
680 (Self_Id, Called_PO, Entry_Call,
681 Entry_Call.Requeue_With_Abort);
682 POO.PO_Service_Entries (Self_Id, Called_PO);
683 STPE.Unlock_Entries (Called_PO);
687 Entry_Calls.Reset_Priority
688 (Self_Id, Entry_Call.Acceptor_Prev_Priority);
691 -- The call does not need to be requeued.
693 Self_Id.Common.Call := Entry_Call.Acceptor_Prev_Call;
694 Entry_Call.Exception_To_Raise := Ex;
700 STPO.Write_Lock (Caller);
702 -- Done with Caller locked to make sure that Wakeup is not lost.
704 if Ex /= Ada.Exceptions.Null_Id then
705 Ada.Exceptions.Save_Occurrence
706 (Caller.Common.Compiler_Data.Current_Excep,
707 Self_Id.Common.Compiler_Data.Current_Excep);
710 Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done);
711 STPO.Unlock (Caller);
717 Entry_Calls.Reset_Priority
718 (Self_Id, Entry_Call.Acceptor_Prev_Priority);
722 Initialization.Undefer_Abort (Self_Id);
724 if Exception_To_Raise /= Ada.Exceptions.Null_Id then
728 -- ??? Do we need to give precedence to Program_Error that might be
729 -- raised due to failure of finalization, over Tasking_Error from
730 -- failure of requeue?
731 end Exceptional_Complete_Rendezvous;
737 -- Call this only with abort deferred and holding lock of T.
739 function Is_Entry_Open (T : Task_ID; E : Task_Entry_Index) return Boolean is
741 pragma Assert (T.Open_Accepts /= null);
743 if T.Open_Accepts /= null then
744 for J in T.Open_Accepts'Range loop
746 pragma Assert (J > 0);
748 if E = T.Open_Accepts (J).S then
757 -------------------------------------
758 -- Requeue_Protected_To_Task_Entry --
759 -------------------------------------
761 procedure Requeue_Protected_To_Task_Entry
762 (Object : STPE.Protection_Entries_Access;
764 E : Task_Entry_Index;
765 With_Abort : Boolean)
767 Entry_Call : constant Entry_Call_Link := Object.Call_In_Progress;
769 pragma Assert (STPO.Self.Deferral_Level > 0);
771 Entry_Call.E := Entry_Index (E);
772 Entry_Call.Called_Task := Acceptor;
773 Entry_Call.Called_PO := Null_Address;
774 Entry_Call.Requeue_With_Abort := With_Abort;
775 Object.Call_In_Progress := null;
776 end Requeue_Protected_To_Task_Entry;
778 ------------------------
779 -- Requeue_Task_Entry --
780 ------------------------
782 procedure Requeue_Task_Entry
784 E : Task_Entry_Index;
785 With_Abort : Boolean)
787 Self_Id : constant Task_ID := STPO.Self;
788 Entry_Call : constant Entry_Call_Link := Self_Id.Common.Call;
791 Initialization.Defer_Abort (Self_Id);
792 Entry_Call.Needs_Requeue := True;
793 Entry_Call.Requeue_With_Abort := With_Abort;
794 Entry_Call.E := Entry_Index (E);
795 Entry_Call.Called_Task := Acceptor;
796 Initialization.Undefer_Abort (Self_Id);
797 end Requeue_Task_Entry;
803 procedure Selective_Wait
804 (Open_Accepts : Accept_List_Access;
805 Select_Mode : Select_Modes;
806 Uninterpreted_Data : out System.Address;
807 Index : out Select_Index)
809 Self_Id : constant Task_ID := STPO.Self;
810 Entry_Call : Entry_Call_Link;
811 Treatment : Select_Treatment;
813 Selection : Select_Index;
814 Open_Alternative : Boolean;
817 Initialization.Defer_Abort (Self_Id);
823 STPO.Write_Lock (Self_Id);
825 if not Self_Id.Callable then
826 pragma Assert (Self_Id.Pending_ATC_Level = 0);
828 pragma Assert (Self_Id.Pending_Action);
830 STPO.Unlock (Self_Id);
836 -- ??? In some cases abort is deferred more than once. Need to
837 -- figure out why this happens.
839 Self_Id.Deferral_Level := 1;
841 Initialization.Undefer_Abort (Self_Id);
843 -- Should never get here ???
845 pragma Assert (False);
846 raise Standard'Abort_Signal;
849 pragma Assert (Open_Accepts /= null);
851 Uninterpreted_Data := Null_Address;
853 Queuing.Select_Task_Entry_Call
854 (Self_Id, Open_Accepts, Entry_Call, Selection, Open_Alternative);
856 -- Determine the kind and disposition of the select.
858 Treatment := Default_Treatment (Select_Mode);
859 Self_Id.Chosen_Index := No_Rendezvous;
861 if Open_Alternative then
862 if Entry_Call /= null then
863 if Open_Accepts (Selection).Null_Body then
864 Treatment := Accept_Alternative_Completed;
866 Setup_For_Rendezvous_With_Body (Entry_Call, Self_Id);
867 Treatment := Accept_Alternative_Selected;
870 Self_Id.Chosen_Index := Selection;
872 elsif Treatment = No_Alternative_Open then
873 Treatment := Accept_Alternative_Open;
877 -- Handle the select according to the disposition selected above.
880 when Accept_Alternative_Selected =>
881 -- Ready to rendezvous
883 Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data;
885 -- In this case the accept body is not Null_Body. Defer abort
886 -- until it gets into the accept body.
888 pragma Assert (Self_Id.Deferral_Level = 1);
890 Initialization.Defer_Abort_Nestable (Self_Id);
891 STPO.Unlock (Self_Id);
893 when Accept_Alternative_Completed =>
894 -- Accept body is null, so rendezvous is over immediately.
896 if Parameters.Runtime_Traces then
897 Send_Trace_Info (M_RDV_Complete, Entry_Call.Self);
900 STPO.Unlock (Self_Id);
901 Caller := Entry_Call.Self;
903 STPO.Write_Lock (Caller);
904 Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done);
905 STPO.Unlock (Caller);
907 when Accept_Alternative_Open =>
910 Self_Id.Open_Accepts := Open_Accepts;
912 (Debug.Trace (Self_Id, "Selective_Wait: wait", 'R'));
914 if Parameters.Runtime_Traces then
915 Send_Trace_Info (W_Select, Self_Id,
916 Integer (Open_Accepts'Length));
919 Wait_For_Call (Self_Id);
921 pragma Assert (Self_Id.Open_Accepts = null);
923 -- Self_Id.Common.Call should already be updated by the Caller if
924 -- not aborted. It might also be ready to do rendezvous even if
925 -- this wakes up due to an abortion.
926 -- Therefore, if the call is not empty we need to do the
927 -- rendezvous if the accept body is not Null_Body.
929 -- Aren't the first two conditions below redundant???
931 if Self_Id.Chosen_Index /= No_Rendezvous
932 and then Self_Id.Common.Call /= null
933 and then not Open_Accepts (Self_Id.Chosen_Index).Null_Body
935 Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data;
937 pragma Assert (Self_Id.Deferral_Level = 1);
939 Initialization.Defer_Abort_Nestable (Self_Id);
941 -- Leave abort deferred until the accept body
944 STPO.Unlock (Self_Id);
946 when Else_Selected =>
947 pragma Assert (Self_Id.Open_Accepts = null);
949 if Parameters.Runtime_Traces then
950 Send_Trace_Info (M_Select_Else);
953 STPO.Unlock (Self_Id);
955 when Terminate_Selected =>
956 -- Terminate alternative is open
958 Self_Id.Open_Accepts := Open_Accepts;
959 Self_Id.Common.State := Acceptor_Sleep;
960 STPO.Unlock (Self_Id);
962 -- Notify ancestors that this task is on a terminate alternative.
964 Utilities.Make_Passive (Self_Id, Task_Completed => False);
966 -- Wait for normal entry call or termination
968 pragma Assert (Self_Id.ATC_Nesting_Level = 1);
970 STPO.Write_Lock (Self_Id);
973 Initialization.Poll_Base_Priority_Change (Self_Id);
974 exit when Self_Id.Open_Accepts = null;
975 Sleep (Self_Id, Acceptor_Sleep);
978 Self_Id.Common.State := Runnable;
980 pragma Assert (Self_Id.Open_Accepts = null);
982 if Self_Id.Terminate_Alternative then
983 -- An entry call should have reset this to False,
984 -- so we must be aborted.
985 -- We cannot be in an async. select, since that
986 -- is not legal, so the abort must be of the entire
987 -- task. Therefore, we do not need to cancel the
988 -- terminate alternative. The cleanup will be done
989 -- in Complete_Master.
991 pragma Assert (Self_Id.Pending_ATC_Level = 0);
992 pragma Assert (Self_Id.Awake_Count = 0);
994 -- Trust that it is OK to fall through.
998 -- Self_Id.Common.Call and Self_Id.Chosen_Index
999 -- should already be updated by the Caller.
1001 if Self_Id.Chosen_Index /= No_Rendezvous
1002 and then not Open_Accepts (Self_Id.Chosen_Index).Null_Body
1004 Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data;
1006 pragma Assert (Self_Id.Deferral_Level = 1);
1008 -- We need an extra defer here, to keep abort
1009 -- deferred until we get into the accept body
1011 Initialization.Defer_Abort_Nestable (Self_Id);
1015 STPO.Unlock (Self_Id);
1017 when No_Alternative_Open =>
1018 -- In this case, Index will be No_Rendezvous on return, which
1019 -- should cause a Program_Error if it is not a Delay_Mode.
1021 -- If delay alternative exists (Delay_Mode) we should suspend
1022 -- until the delay expires.
1024 Self_Id.Open_Accepts := null;
1026 if Select_Mode = Delay_Mode then
1027 Self_Id.Common.State := Delay_Sleep;
1030 Initialization.Poll_Base_Priority_Change (Self_Id);
1032 Self_Id.Pending_ATC_Level < Self_Id.ATC_Nesting_Level;
1033 Sleep (Self_Id, Delay_Sleep);
1036 Self_Id.Common.State := Runnable;
1037 STPO.Unlock (Self_Id);
1040 STPO.Unlock (Self_Id);
1046 Initialization.Undefer_Abort (Self_Id);
1047 Ada.Exceptions.Raise_Exception
1048 (Program_Error'Identity, "Entry call not a delay mode");
1056 -- Caller has been chosen.
1057 -- Self_Id.Common.Call should already be updated by the Caller.
1058 -- Self_Id.Chosen_Index should either be updated by the Caller
1059 -- or by Test_Selective_Wait.
1060 -- On return, we sill start rendezvous unless the accept body is
1061 -- null. In the latter case, we will have already completed the RV.
1063 Index := Self_Id.Chosen_Index;
1064 Initialization.Undefer_Abort_Nestable (Self_Id);
1067 ------------------------------------
1068 -- Setup_For_Rendezvous_With_Body --
1069 ------------------------------------
1071 -- Call this only with abort deferred and holding lock of Acceptor.
1073 procedure Setup_For_Rendezvous_With_Body
1074 (Entry_Call : Entry_Call_Link;
1075 Acceptor : Task_ID) is
1077 Entry_Call.Acceptor_Prev_Call := Acceptor.Common.Call;
1078 Acceptor.Common.Call := Entry_Call;
1080 if Entry_Call.State = Now_Abortable then
1081 Entry_Call.State := Was_Abortable;
1084 Boost_Priority (Entry_Call, Acceptor);
1085 end Setup_For_Rendezvous_With_Body;
1091 function Task_Count (E : Task_Entry_Index) return Natural is
1092 Self_Id : constant Task_ID := STPO.Self;
1093 Return_Count : Natural;
1096 Initialization.Defer_Abort (Self_Id);
1102 STPO.Write_Lock (Self_Id);
1103 Return_Count := Queuing.Count_Waiting (Self_Id.Entry_Queues (E));
1104 STPO.Unlock (Self_Id);
1110 Initialization.Undefer_Abort (Self_Id);
1111 return Return_Count;
1114 ----------------------
1115 -- Task_Do_Or_Queue --
1116 ----------------------
1118 function Task_Do_Or_Queue
1120 Entry_Call : Entry_Call_Link;
1121 With_Abort : Boolean) return Boolean
1123 E : constant Task_Entry_Index :=
1124 Task_Entry_Index (Entry_Call.E);
1125 Old_State : constant Entry_Call_State := Entry_Call.State;
1126 Acceptor : constant Task_ID := Entry_Call.Called_Task;
1127 Parent : constant Task_ID := Acceptor.Common.Parent;
1128 Parent_Locked : Boolean := False;
1129 Null_Body : Boolean;
1132 -- Find out whether Entry_Call can be accepted immediately.
1133 -- If the Acceptor is not callable, return False.
1134 -- If the rendezvous can start, initiate it.
1135 -- If the accept-body is trivial, also complete the rendezvous.
1136 -- If the acceptor is not ready, enqueue the call.
1138 -- This should have a special case for Accept_Call and Accept_Trivial,
1139 -- so that we don't have the loop setup overhead, below.
1141 -- The call state Done is used here and elsewhere to include both the
1142 -- case of normal successful completion, and the case of an exception
1143 -- being raised. The difference is that if an exception is raised no one
1144 -- will pay attention to the fact that State = Done. Instead the
1145 -- exception will be raised in Undefer_Abort, and control will skip past
1146 -- the place where we normally would resume from an entry call.
1148 pragma Assert (not Queuing.Onqueue (Entry_Call));
1150 -- We rely that the call is off-queue for protection, that the caller
1151 -- will not exit the Entry_Caller_Sleep, and so will not reuse the call
1152 -- record for another call.
1153 -- We rely on the Caller's lock for call State mod's.
1155 -- We can't lock Acceptor.Parent while holding Acceptor,
1156 -- so lock it in advance if we expect to need to lock it.
1158 if Acceptor.Terminate_Alternative then
1159 STPO.Write_Lock (Parent);
1160 Parent_Locked := True;
1163 STPO.Write_Lock (Acceptor);
1165 -- If the acceptor is not callable, abort the call and return False.
1167 if not Acceptor.Callable then
1168 STPO.Unlock (Acceptor);
1170 if Parent_Locked then
1171 STPO.Unlock (Parent);
1174 pragma Assert (Entry_Call.State < Done);
1176 -- In case we are not the caller, set up the caller
1177 -- to raise Tasking_Error when it wakes up.
1179 STPO.Write_Lock (Entry_Call.Self);
1180 Entry_Call.Exception_To_Raise := Tasking_Error'Identity;
1181 Initialization.Wakeup_Entry_Caller (Self_ID, Entry_Call, Done);
1182 STPO.Unlock (Entry_Call.Self);
1187 -- Try to serve the call immediately.
1189 if Acceptor.Open_Accepts /= null then
1190 for J in Acceptor.Open_Accepts'Range loop
1191 if Entry_Call.E = Entry_Index (Acceptor.Open_Accepts (J).S) then
1193 -- Commit acceptor to rendezvous with us.
1195 Acceptor.Chosen_Index := J;
1196 Null_Body := Acceptor.Open_Accepts (J).Null_Body;
1197 Acceptor.Open_Accepts := null;
1199 -- Prevent abort while call is being served.
1201 if Entry_Call.State = Now_Abortable then
1202 Entry_Call.State := Was_Abortable;
1205 if Acceptor.Terminate_Alternative then
1206 -- Cancel terminate alternative.
1207 -- See matching code in Selective_Wait and
1208 -- Vulnerable_Complete_Master.
1210 Acceptor.Terminate_Alternative := False;
1211 Acceptor.Awake_Count := Acceptor.Awake_Count + 1;
1213 if Acceptor.Awake_Count = 1 then
1215 -- Notify parent that acceptor is awake.
1217 pragma Assert (Parent.Awake_Count > 0);
1219 Parent.Awake_Count := Parent.Awake_Count + 1;
1221 if Parent.Common.State = Master_Completion_Sleep
1222 and then Acceptor.Master_of_Task = Parent.Master_Within
1224 Parent.Common.Wait_Count :=
1225 Parent.Common.Wait_Count + 1;
1231 -- Rendezvous is over immediately.
1233 STPO.Wakeup (Acceptor, Acceptor_Sleep);
1234 STPO.Unlock (Acceptor);
1236 if Parent_Locked then
1237 STPO.Unlock (Parent);
1240 STPO.Write_Lock (Entry_Call.Self);
1241 Initialization.Wakeup_Entry_Caller
1242 (Self_ID, Entry_Call, Done);
1243 STPO.Unlock (Entry_Call.Self);
1246 Setup_For_Rendezvous_With_Body (Entry_Call, Acceptor);
1248 -- For terminate_alternative, acceptor may not be
1249 -- asleep yet, so we skip the wakeup
1251 if Acceptor.Common.State /= Runnable then
1252 STPO.Wakeup (Acceptor, Acceptor_Sleep);
1255 STPO.Unlock (Acceptor);
1257 if Parent_Locked then
1258 STPO.Unlock (Parent);
1266 -- The acceptor is accepting, but not this entry.
1269 -- If the acceptor was ready to accept this call,
1270 -- we would not have gotten this far, so now we should
1271 -- (re)enqueue the call, if the mode permits that.
1273 if Entry_Call.Mode /= Conditional_Call
1274 or else not With_Abort
1276 -- Timed_Call, Simple_Call, or Asynchronous_Call
1278 Queuing.Enqueue (Acceptor.Entry_Queues (E), Entry_Call);
1280 -- Update abortability of call
1282 pragma Assert (Old_State < Done);
1284 Entry_Call.State := New_State (With_Abort, Entry_Call.State);
1286 STPO.Unlock (Acceptor);
1288 if Parent_Locked then
1289 STPO.Unlock (Parent);
1292 if Old_State /= Entry_Call.State
1293 and then Entry_Call.State = Now_Abortable
1294 and then Entry_Call.Mode > Simple_Call
1295 and then Entry_Call.Self /= Self_ID
1297 -- Asynchronous_Call or Conditional_Call
1300 -- Because of ATCB lock ordering rule
1302 STPO.Write_Lock (Entry_Call.Self);
1304 if Entry_Call.Self.Common.State = Async_Select_Sleep then
1306 -- Caller may not yet have reached wait-point
1308 STPO.Wakeup (Entry_Call.Self, Async_Select_Sleep);
1311 STPO.Unlock (Entry_Call.Self);
1315 -- Conditional_Call and With_Abort
1317 STPO.Unlock (Acceptor);
1319 if Parent_Locked then
1320 STPO.Unlock (Parent);
1323 STPO.Write_Lock (Entry_Call.Self);
1325 pragma Assert (Entry_Call.State >= Was_Abortable);
1327 Initialization.Wakeup_Entry_Caller (Self_ID, Entry_Call, Cancelled);
1328 STPO.Unlock (Entry_Call.Self);
1332 end Task_Do_Or_Queue;
1334 ---------------------
1335 -- Task_Entry_Call --
1336 ---------------------
1338 procedure Task_Entry_Call
1339 (Acceptor : Task_ID;
1340 E : Task_Entry_Index;
1341 Uninterpreted_Data : System.Address;
1343 Rendezvous_Successful : out Boolean)
1345 Self_Id : constant Task_ID := STPO.Self;
1346 Entry_Call : Entry_Call_Link;
1349 if Parameters.Runtime_Traces then
1350 Send_Trace_Info (W_Call, Acceptor, Entry_Index (E));
1353 if Mode = Simple_Call or else Mode = Conditional_Call then
1355 (Acceptor, E, Uninterpreted_Data, Mode, Rendezvous_Successful);
1358 -- This is an asynchronous call
1360 -- Abortion must already be deferred by the compiler-generated
1361 -- code. Without this, an abortion that occurs between the time
1362 -- that this call is made and the time that the abortable part's
1363 -- cleanup handler is set up might miss the cleanup handler and
1364 -- leave the call pending.
1366 Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level + 1;
1368 (Debug.Trace (Self_Id, "TEC: entered ATC level: " &
1369 ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A'));
1370 Entry_Call := Self_Id.Entry_Calls (Self_Id.ATC_Nesting_Level)'Access;
1371 Entry_Call.Next := null;
1372 Entry_Call.Mode := Mode;
1373 Entry_Call.Cancellation_Attempted := False;
1374 Entry_Call.State := Not_Yet_Abortable;
1375 Entry_Call.E := Entry_Index (E);
1376 Entry_Call.Prio := Get_Priority (Self_Id);
1377 Entry_Call.Uninterpreted_Data := Uninterpreted_Data;
1378 Entry_Call.Called_Task := Acceptor;
1379 Entry_Call.Called_PO := Null_Address;
1380 Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id;
1386 if not Task_Do_Or_Queue
1387 (Self_Id, Entry_Call, With_Abort => True)
1389 Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level - 1;
1391 (Debug.Trace (Self_Id, "TEC: exited to ATC level: " &
1392 ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A'));
1398 Initialization.Undefer_Abort (Self_Id);
1400 if Parameters.Runtime_Traces then
1401 Send_Trace_Info (E_Missed, Acceptor);
1404 raise Tasking_Error;
1407 -- The following is special for async. entry calls.
1408 -- If the call was not queued abortably, we need to wait until
1409 -- it is before proceeding with the abortable part.
1411 -- Wait_Until_Abortable can be called unconditionally here,
1412 -- but it is expensive.
1414 if Entry_Call.State < Was_Abortable then
1415 Entry_Calls.Wait_Until_Abortable (Self_Id, Entry_Call);
1422 -- Note: following assignment needs to be atomic.
1424 Rendezvous_Successful := Entry_Call.State = Done;
1426 end Task_Entry_Call;
1428 -----------------------
1429 -- Task_Entry_Caller --
1430 -----------------------
1432 function Task_Entry_Caller (D : Task_Entry_Nesting_Depth) return Task_ID is
1433 Self_Id : constant Task_ID := STPO.Self;
1434 Entry_Call : Entry_Call_Link;
1437 Entry_Call := Self_Id.Common.Call;
1439 for Depth in 1 .. D loop
1440 Entry_Call := Entry_Call.Acceptor_Prev_Call;
1441 pragma Assert (Entry_Call /= null);
1444 return Entry_Call.Self;
1445 end Task_Entry_Caller;
1447 --------------------------
1448 -- Timed_Selective_Wait --
1449 --------------------------
1451 procedure Timed_Selective_Wait
1452 (Open_Accepts : Accept_List_Access;
1453 Select_Mode : Select_Modes;
1454 Uninterpreted_Data : out System.Address;
1457 Index : out Select_Index)
1459 Self_Id : constant Task_ID := STPO.Self;
1460 Treatment : Select_Treatment;
1461 Entry_Call : Entry_Call_Link;
1463 Selection : Select_Index;
1464 Open_Alternative : Boolean;
1465 Timedout : Boolean := False;
1466 Yielded : Boolean := True;
1469 pragma Assert (Select_Mode = Delay_Mode);
1471 Initialization.Defer_Abort (Self_Id);
1473 -- If we are aborted here, the effect will be pending
1479 STPO.Write_Lock (Self_Id);
1481 if not Self_Id.Callable then
1482 pragma Assert (Self_Id.Pending_ATC_Level = 0);
1484 pragma Assert (Self_Id.Pending_Action);
1486 STPO.Unlock (Self_Id);
1492 Initialization.Undefer_Abort (Self_Id);
1494 -- Should never get here ???
1496 pragma Assert (False);
1497 raise Standard'Abort_Signal;
1500 Uninterpreted_Data := Null_Address;
1502 pragma Assert (Open_Accepts /= null);
1504 Queuing.Select_Task_Entry_Call
1505 (Self_Id, Open_Accepts, Entry_Call, Selection, Open_Alternative);
1507 -- Determine the kind and disposition of the select.
1509 Treatment := Default_Treatment (Select_Mode);
1510 Self_Id.Chosen_Index := No_Rendezvous;
1512 if Open_Alternative then
1513 if Entry_Call /= null then
1514 if Open_Accepts (Selection).Null_Body then
1515 Treatment := Accept_Alternative_Completed;
1518 Setup_For_Rendezvous_With_Body (Entry_Call, Self_Id);
1519 Treatment := Accept_Alternative_Selected;
1522 Self_Id.Chosen_Index := Selection;
1524 elsif Treatment = No_Alternative_Open then
1525 Treatment := Accept_Alternative_Open;
1529 -- Handle the select according to the disposition selected above.
1532 when Accept_Alternative_Selected =>
1533 -- Ready to rendezvous
1534 -- In this case the accept body is not Null_Body. Defer abort
1535 -- until it gets into the accept body.
1537 Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data;
1538 Initialization.Defer_Abort (Self_Id);
1539 STPO.Unlock (Self_Id);
1541 when Accept_Alternative_Completed =>
1542 -- Rendezvous is over
1544 if Parameters.Runtime_Traces then
1545 Send_Trace_Info (M_RDV_Complete, Entry_Call.Self);
1548 STPO.Unlock (Self_Id);
1549 Caller := Entry_Call.Self;
1551 STPO.Write_Lock (Caller);
1552 Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done);
1553 STPO.Unlock (Caller);
1555 when Accept_Alternative_Open =>
1558 Self_Id.Open_Accepts := Open_Accepts;
1560 -- Wait for a normal call and a pending action until the
1561 -- Wakeup_Time is reached.
1563 Self_Id.Common.State := Acceptor_Sleep;
1566 Initialization.Poll_Base_Priority_Change (Self_Id);
1567 exit when Self_Id.Open_Accepts = null;
1570 Sleep (Self_Id, Acceptor_Sleep);
1572 if Parameters.Runtime_Traces then
1573 Send_Trace_Info (WT_Select,
1575 Integer (Open_Accepts'Length),
1579 STPO.Timed_Sleep (Self_Id, Timeout, Mode,
1580 Acceptor_Sleep, Timedout, Yielded);
1584 Self_Id.Open_Accepts := null;
1586 if Parameters.Runtime_Traces then
1587 Send_Trace_Info (E_Timeout);
1592 Self_Id.Common.State := Runnable;
1594 -- Self_Id.Common.Call should already be updated by the Caller if
1595 -- not aborted. It might also be ready to do rendezvous even if
1596 -- this wakes up due to an abortion.
1597 -- Therefore, if the call is not empty we need to do the
1598 -- rendezvous if the accept body is not Null_Body.
1600 if Self_Id.Chosen_Index /= No_Rendezvous
1601 and then Self_Id.Common.Call /= null
1602 and then not Open_Accepts (Self_Id.Chosen_Index).Null_Body
1604 Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data;
1606 pragma Assert (Self_Id.Deferral_Level = 1);
1608 Initialization.Defer_Abort_Nestable (Self_Id);
1610 -- Leave abort deferred until the accept body
1613 STPO.Unlock (Self_Id);
1615 when No_Alternative_Open =>
1616 -- In this case, Index will be No_Rendezvous on return. We sleep
1617 -- for the time we need to.
1618 -- Wait for a signal or timeout. A wakeup can be made
1619 -- for several reasons:
1620 -- 1) Delay is expired
1621 -- 2) Pending_Action needs to be checked
1622 -- (Abortion, Priority change)
1623 -- 3) Spurious wakeup
1625 Self_Id.Open_Accepts := null;
1626 Self_Id.Common.State := Acceptor_Sleep;
1628 Initialization.Poll_Base_Priority_Change (Self_Id);
1630 STPO.Timed_Sleep (Self_Id, Timeout, Mode, Acceptor_Sleep,
1633 Self_Id.Common.State := Runnable;
1635 STPO.Unlock (Self_Id);
1638 -- Should never get here
1639 pragma Assert (False);
1651 -- Caller has been chosen
1653 -- Self_Id.Common.Call should already be updated by the Caller
1655 -- Self_Id.Chosen_Index should either be updated by the Caller
1656 -- or by Test_Selective_Wait
1658 Index := Self_Id.Chosen_Index;
1659 Initialization.Undefer_Abort_Nestable (Self_Id);
1661 -- Start rendezvous, if not already completed
1662 end Timed_Selective_Wait;
1664 ---------------------------
1665 -- Timed_Task_Entry_Call --
1666 ---------------------------
1668 procedure Timed_Task_Entry_Call
1669 (Acceptor : Task_ID;
1670 E : Task_Entry_Index;
1671 Uninterpreted_Data : System.Address;
1674 Rendezvous_Successful : out Boolean)
1676 Self_Id : constant Task_ID := STPO.Self;
1678 Entry_Call : Entry_Call_Link;
1682 Initialization.Defer_Abort (Self_Id);
1683 Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level + 1;
1686 (Debug.Trace (Self_Id, "TTEC: entered ATC level: " &
1687 ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A'));
1689 if Parameters.Runtime_Traces then
1690 Send_Trace_Info (WT_Call, Acceptor,
1691 Entry_Index (E), Timeout);
1694 Level := Self_Id.ATC_Nesting_Level;
1695 Entry_Call := Self_Id.Entry_Calls (Level)'Access;
1696 Entry_Call.Next := null;
1697 Entry_Call.Mode := Timed_Call;
1698 Entry_Call.Cancellation_Attempted := False;
1700 -- If this is a call made inside of an abort deferred region,
1701 -- the call should be never abortable.
1703 if Self_Id.Deferral_Level > 1 then
1704 Entry_Call.State := Never_Abortable;
1706 Entry_Call.State := Now_Abortable;
1709 Entry_Call.E := Entry_Index (E);
1710 Entry_Call.Prio := Get_Priority (Self_Id);
1711 Entry_Call.Uninterpreted_Data := Uninterpreted_Data;
1712 Entry_Call.Called_Task := Acceptor;
1713 Entry_Call.Called_PO := Null_Address;
1714 Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id;
1716 -- Note: the caller will undefer abortion on return (see WARNING above)
1722 if not Task_Do_Or_Queue
1723 (Self_Id, Entry_Call, With_Abort => True)
1725 Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level - 1;
1728 (Debug.Trace (Self_Id, "TTEC: exited to ATC level: " &
1729 ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A'));
1735 Initialization.Undefer_Abort (Self_Id);
1737 if Parameters.Runtime_Traces then
1738 Send_Trace_Info (E_Missed, Acceptor);
1740 raise Tasking_Error;
1743 Write_Lock (Self_Id);
1744 Entry_Calls.Wait_For_Completion_With_Timeout
1745 (Entry_Call, Timeout, Mode, Yielded);
1752 -- ??? Do we need to yield in case Yielded is False
1754 Rendezvous_Successful := Entry_Call.State = Done;
1755 Initialization.Undefer_Abort (Self_Id);
1756 Entry_Calls.Check_Exception (Self_Id, Entry_Call);
1757 end Timed_Task_Entry_Call;
1763 -- Call this only with abort deferred and holding lock of Self_Id.
1764 -- Wait for normal call and a pending action.
1766 procedure Wait_For_Call (Self_Id : Task_ID) is
1768 Self_Id.Common.State := Acceptor_Sleep;
1771 Initialization.Poll_Base_Priority_Change (Self_Id);
1773 exit when Self_Id.Open_Accepts = null;
1775 Sleep (Self_Id, Acceptor_Sleep);
1778 Self_Id.Common.State := Runnable;
1781 end System.Tasking.Rendezvous;