1 ------------------------------------------------------------------------------
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- S Y S T E M . T A S K I N G . I N I T I A L I Z A T I O N --
9 -- Copyright (C) 1992-2004, 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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 pragma Style_Checks (All_Checks);
35 -- Turn off subprogram alpha ordering check, since we group soft link
36 -- bodies and dummy soft link bodies together separately in this unit.
39 -- Turn polling off for this package. We don't need polling during any
40 -- of the routines in this package, and more to the point, if we try
41 -- to poll it can cause infinite loops.
44 -- used for Exception_Occurrence_Access.
47 pragma Elaborate_All (System.Tasking);
48 -- ensure that the first step initializations have been performed
50 with System.Task_Primitives;
53 with System.Task_Primitives.Operations;
54 -- used for Set_Priority
59 with System.Soft_Links;
60 -- used for the non-tasking routines (*_NT) that refer to global data.
61 -- They are needed here before the tasking run time has been elaborated.
63 with System.Soft_Links.Tasking;
64 -- Used for Init_Tasking_Soft_Links
66 with System.Tasking.Debug;
69 with System.Stack_Checking;
71 with System.Parameters;
72 -- used for Single_Lock
74 package body System.Tasking.Initialization is
76 package STPO renames System.Task_Primitives.Operations;
77 package SSL renames System.Soft_Links;
78 package AE renames Ada.Exceptions;
81 use Task_Primitives.Operations;
83 Global_Task_Lock : aliased System.Task_Primitives.RTS_Lock;
84 -- This is a global lock; it is used to execute in mutual exclusion
85 -- from all other tasks. It is only used by Task_Lock,
86 -- Task_Unlock, and Final_Task_Unlock.
88 function Current_Target_Exception return AE.Exception_Occurrence;
90 (Ada, Current_Target_Exception, "__gnat_current_target_exception");
91 -- Import this subprogram from the private part of Ada.Exceptions.
93 ----------------------------------------------------------------------
94 -- Tasking versions of some services needed by non-tasking programs --
95 ----------------------------------------------------------------------
98 -- Locks out other tasks. Preceding a section of code by Task_Lock and
99 -- following it by Task_Unlock creates a critical region. This is used
100 -- for ensuring that a region of non-tasking code (such as code used to
101 -- allocate memory) is tasking safe. Note that it is valid for calls to
102 -- Task_Lock/Task_Unlock to be nested, and this must work properly, i.e.
103 -- only the corresponding outer level Task_Unlock will actually unlock.
105 procedure Task_Unlock;
106 -- Releases lock previously set by call to Task_Lock. In the nested case,
107 -- all nested locks must be released before other tasks competing for the
108 -- tasking lock are released.
110 function Get_Exc_Stack_Addr return Address;
111 -- Get the exception stack for the current task
113 procedure Set_Exc_Stack_Addr (Self_ID : Address; Addr : Address);
114 -- Self_ID is the Task_Id of the task that gets the exception stack.
115 -- For Self_ID = Null_Address, the current task gets the exception stack.
117 function Get_Stack_Info return Stack_Checking.Stack_Access;
118 -- Get access to the current task's Stack_Info
120 procedure Update_Exception
121 (X : AE.Exception_Occurrence := Current_Target_Exception);
122 -- Handle exception setting and check for pending actions
124 function Task_Name return String;
125 -- Returns current task's name
127 ------------------------
128 -- Local Subprograms --
129 ------------------------
131 procedure Do_Pending_Action (Self_ID : Task_Id);
132 -- This is introduced to allow more efficient
133 -- in-line expansion of Undefer_Abort.
135 ----------------------------
136 -- Tasking Initialization --
137 ----------------------------
139 procedure Gnat_Install_Locks (Lock, Unlock : SSL.No_Param_Proc);
140 pragma Import (C, Gnat_Install_Locks, "__gnatlib_install_locks");
141 -- Used by Init_RTS to install procedure Lock and Unlock for the
142 -- thread locking. This has no effect on GCC 2. For GCC 3,
143 -- it has an effect only if gcc is configured with
144 -- --enable_threads=gnat.
147 -- This procedure completes the initialization of the GNARL. The first
148 -- part of the initialization is done in the body of System.Tasking.
149 -- It consists of initializing global locks, and installing tasking
150 -- versions of certain operations used by the compiler. Init_RTS is called
151 -- during elaboration.
153 --------------------------
154 -- Change_Base_Priority --
155 --------------------------
157 -- Call only with abort deferred and holding Self_ID locked.
159 procedure Change_Base_Priority (T : Task_Id) is
161 if T.Common.Base_Priority /= T.New_Base_Priority then
162 T.Common.Base_Priority := T.New_Base_Priority;
163 Set_Priority (T, T.Common.Base_Priority);
165 end Change_Base_Priority;
167 ------------------------
168 -- Check_Abort_Status --
169 ------------------------
171 function Check_Abort_Status return Integer is
172 Self_ID : constant Task_Id := Self;
174 if Self_ID /= null and then Self_ID.Deferral_Level = 0
175 and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level
181 end Check_Abort_Status;
187 procedure Defer_Abort (Self_ID : Task_Id) is
189 if No_Abort and then not Dynamic_Priority_Support then
193 pragma Assert (Self_ID.Deferral_Level = 0);
196 -- (Self_ID.Pending_ATC_Level >= Self_ID.ATC_Nesting_Level);
198 -- The above check has been useful in detecting mismatched defer/undefer
199 -- pairs. You may uncomment it when testing on systems that support
202 -- If the OS supports preemptive abort (e.g. pthread_kill), it should
203 -- have happened already. A problem is with systems that do not support
204 -- preemptive abort, and so rely on polling. On such systems we may get
205 -- false failures of the assertion, since polling for pending abort does
206 -- no occur until the abort undefer operation.
208 -- Even on systems that only poll for abort, the assertion may be useful
209 -- for catching missed abort completion polling points. The operations
210 -- that undefer abort poll for pending aborts. This covers most of the
211 -- places where the core Ada semantics require abort to be caught,
212 -- without any special attention. However, this generally happens on
213 -- exit from runtime system call, which means a pending abort will not
214 -- be noticed on the way into the runtime system. We considered adding a
215 -- check for pending aborts at this point, but chose not to, because of
216 -- the overhead. Instead, we searched for RTS calls where abort
217 -- completion is required and a task could go farther than Ada allows
218 -- before undeferring abort; we then modified the code to ensure the
219 -- abort would be detected.
221 Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1;
224 --------------------------
225 -- Defer_Abort_Nestable --
226 --------------------------
228 procedure Defer_Abort_Nestable (Self_ID : Task_Id) is
230 if No_Abort and then not Dynamic_Priority_Support then
235 -- ((Self_ID.Pending_ATC_Level >= Self_ID.ATC_Nesting_Level or else
236 -- Self_ID.Deferral_Level > 0));
238 -- See comment in Defer_Abort on the situations in which it may be
239 -- useful to uncomment the above assertion.
241 Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1;
242 end Defer_Abort_Nestable;
248 procedure Defer_Abortion is
252 if No_Abort and then not Dynamic_Priority_Support then
256 Self_ID := STPO.Self;
257 Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1;
260 -----------------------
261 -- Do_Pending_Action --
262 -----------------------
264 -- Call only when holding no locks
266 procedure Do_Pending_Action (Self_ID : Task_Id) is
267 use type Ada.Exceptions.Exception_Id;
270 pragma Assert (Self_ID = Self and then Self_ID.Deferral_Level = 0);
272 -- Needs loop to recheck for pending action in case a new one occurred
273 -- while we had abort deferred below.
276 -- Temporarily defer abortion so that we can lock Self_ID.
278 Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1;
284 Write_Lock (Self_ID);
285 Self_ID.Pending_Action := False;
286 Poll_Base_Priority_Change (Self_ID);
293 -- Restore the original Deferral value.
295 Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1;
297 if not Self_ID.Pending_Action then
298 if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level then
299 if not Self_ID.Aborting then
300 Self_ID.Aborting := True;
302 (Debug.Trace (Self_ID, "raise Abort_Signal", 'B'));
303 raise Standard'Abort_Signal;
305 pragma Assert (not Self_ID.ATC_Hack);
307 elsif Self_ID.ATC_Hack then
308 -- The solution really belongs in the Abort_Signal handler
309 -- for async. entry calls. The present hack is very
310 -- fragile. It relies that the very next point after
311 -- Exit_One_ATC_Level at which the task becomes abortable
312 -- will be the call to Undefer_Abort in the
313 -- Abort_Signal handler.
315 Self_ID.ATC_Hack := False;
319 (Self_ID, "raise Abort_Signal (ATC hack)", 'B'));
320 raise Standard'Abort_Signal;
327 end Do_Pending_Action;
329 -----------------------
330 -- Final_Task_Unlock --
331 -----------------------
333 -- This version is only for use in Terminate_Task, when the task
334 -- is relinquishing further rights to its own ATCB.
335 -- There is a very interesting potential race condition there, where
336 -- the old task may run concurrently with a new task that is allocated
337 -- the old tasks (now reused) ATCB. The critical thing here is to
338 -- not make any reference to the ATCB after the lock is released.
339 -- See also comments on Terminate_Task and Unlock.
341 procedure Final_Task_Unlock (Self_ID : Task_Id) is
343 pragma Assert (Self_ID.Global_Task_Lock_Nesting = 1);
344 Unlock (Global_Task_Lock'Access, Global_Lock => True);
345 end Final_Task_Unlock;
351 procedure Init_RTS is
355 -- Terminate run time (regular vs restricted) specific initialization
356 -- of the environment task.
358 Self_Id := Environment_Task;
359 Self_Id.Master_of_Task := Environment_Task_Level;
360 Self_Id.Master_Within := Self_Id.Master_of_Task + 1;
362 for L in Self_Id.Entry_Calls'Range loop
363 Self_Id.Entry_Calls (L).Self := Self_Id;
364 Self_Id.Entry_Calls (L).Level := L;
367 Self_Id.Awake_Count := 1;
368 Self_Id.Alive_Count := 1;
370 Self_Id.Master_Within := Library_Task_Level;
371 -- Normally, a task starts out with internal master nesting level
372 -- one larger than external master nesting level. It is incremented
373 -- to one by Enter_Master, which is called in the task body only if
374 -- the compiler thinks the task may have dependent tasks. There is no
375 -- corresponding call to Enter_Master for the environment task, so we
376 -- would need to increment it to 2 here. Instead, we set it to 3.
377 -- By doing this we reserve the level 2 for server tasks of the runtime
378 -- system. The environment task does not need to wait for these server
380 -- Initialize lock used to implement mutual exclusion between all tasks
382 Initialize_Lock (Global_Task_Lock'Access, STPO.Global_Task_Level);
384 -- Notify that the tasking run time has been elaborated so that
385 -- the tasking version of the soft links can be used.
387 if not No_Abort or else Dynamic_Priority_Support then
388 SSL.Abort_Defer := Defer_Abortion'Access;
389 SSL.Abort_Undefer := Undefer_Abortion'Access;
392 SSL.Update_Exception := Update_Exception'Access;
393 SSL.Lock_Task := Task_Lock'Access;
394 SSL.Unlock_Task := Task_Unlock'Access;
395 SSL.Get_Exc_Stack_Addr := Get_Exc_Stack_Addr'Access;
396 SSL.Set_Exc_Stack_Addr := Set_Exc_Stack_Addr'Access;
397 SSL.Check_Abort_Status := Check_Abort_Status'Access;
398 SSL.Get_Stack_Info := Get_Stack_Info'Access;
399 SSL.Task_Name := Task_Name'Access;
401 SSL.Set_Exc_Stack_Addr (Null_Address, SSL.Get_Exc_Stack_Addr_NT);
403 -- Initialize the tasking soft links (if not done yet) that are common
404 -- to the full and the restricted run times.
406 SSL.Tasking.Init_Tasking_Soft_Links;
408 -- Install tasking locks in the GCC runtime.
410 Gnat_Install_Locks (Task_Lock'Access, Task_Unlock'Access);
412 -- Abortion is deferred in a new ATCB, so we need to undefer abortion
413 -- at this stage to make the environment task abortable.
415 Undefer_Abort (Environment_Task);
418 ---------------------------
419 -- Locked_Abort_To_Level--
420 ---------------------------
422 -- Abort a task to the specified ATC nesting level.
423 -- Call this only with T locked.
425 -- An earlier version of this code contained a call to Wakeup. That
426 -- should not be necessary here, if Abort_Task is implemented correctly,
427 -- since Abort_Task should include the effect of Wakeup. However, the
428 -- above call was in earlier versions of this file, and at least for
429 -- some targets Abort_Task has not beek doing Wakeup. It should not
430 -- hurt to uncomment the above call, until the error is corrected for
433 -- See extended comments in package body System.Tasking.Abortion
434 -- for the overall design of the implementation of task abort.
436 -- If the task is sleeping it will be in an abort-deferred region,
437 -- and will not have Abort_Signal raised by Abort_Task.
438 -- Such an "abort deferral" is just to protect the RTS internals,
439 -- and not necessarily required to enforce Ada semantics.
440 -- Abort_Task should wake the task up and let it decide if it wants
441 -- to complete the aborted construct immediately.
443 -- Note that the effect of the lowl-level Abort_Task is not persistent.
444 -- If the target task is not blocked, this wakeup will be missed.
446 -- We don't bother calling Abort_Task if this task is aborting itself,
447 -- since we are inside the RTS and have abort deferred. Similarly, We
448 -- don't bother to call Abort_Task if T is terminated, since there is
449 -- no need to abort a terminated task, and it could be dangerous to try
450 -- if the task has stopped executing.
452 -- Note that an earlier version of this code had some false reasoning
453 -- about being able to reliably wake up a task that had suspended on
454 -- a blocking system call that does not atomically relase the task's
455 -- lock (e.g., UNIX nanosleep, which we once thought could be used to
456 -- implement delays). That still left the possibility of missed
459 -- We cannot safely call Vulnerable_Complete_Activation here,
460 -- since that requires locking Self_ID.Parent. The anti-deadlock
461 -- lock ordering rules would then require us to release the lock
462 -- on Self_ID first, which would create a timing window for other
463 -- tasks to lock Self_ID. This is significant for tasks that may be
464 -- aborted before their execution can enter the task body, and so
465 -- they do not get a chance to call Complete_Task. The actual work
466 -- for this case is done in Terminate_Task.
468 procedure Locked_Abort_To_Level
474 if not T.Aborting and then T /= Self_ID then
475 case T.Common.State is
476 when Unactivated | Terminated =>
477 pragma Assert (False);
481 -- This is needed to cancel an asynchronous protected entry
482 -- call during a requeue with abort.
485 (T.ATC_Nesting_Level).Cancellation_Attempted := True;
487 when Interrupt_Server_Blocked_On_Event_Flag =>
492 Interrupt_Server_Idle_Sleep |
493 Interrupt_Server_Blocked_Interrupt_Sleep |
496 Wakeup (T, T.Common.State);
498 when Acceptor_Sleep =>
499 T.Open_Accepts := null;
500 Wakeup (T, T.Common.State);
502 when Entry_Caller_Sleep =>
504 (T.ATC_Nesting_Level).Cancellation_Attempted := True;
505 Wakeup (T, T.Common.State);
507 when Activator_Sleep |
508 Master_Completion_Sleep |
509 Master_Phase_2_Sleep |
515 if T.Pending_ATC_Level > L then
516 T.Pending_ATC_Level := L;
517 T.Pending_Action := True;
523 -- This prevents aborted task from accepting calls
527 -- The test above is just a heuristic, to reduce wasteful
528 -- calls to Abort_Task. We are holding T locked, and this
529 -- value will not be set to False except with T also locked,
530 -- inside Exit_One_ATC_Level, so we should not miss wakeups.
532 if T.Common.State = Acceptor_Sleep then
533 T.Open_Accepts := null;
536 elsif T /= Self_ID and then
537 (T.Common.State = Runnable
538 or else T.Common.State = Interrupt_Server_Blocked_On_Event_Flag)
539 -- The task is blocked on a system call waiting for the
540 -- completion event. In this case Abort_Task may need to take
541 -- special action in order to succeed. Example system: VMS.
547 end Locked_Abort_To_Level;
549 -------------------------------
550 -- Poll_Base_Priority_Change --
551 -------------------------------
553 -- Poll for pending base priority change and for held tasks.
554 -- This should always be called with (only) Self_ID locked.
555 -- It may temporarily release Self_ID's lock.
557 -- The call to Yield is to force enqueuing at the
558 -- tail of the dispatching queue.
560 -- We must unlock Self_ID for this to take effect,
561 -- since we are inheriting high active priority from the lock.
563 -- See also Poll_Base_Priority_Change_At_Entry_Call,
564 -- in package System.Tasking.Entry_Calls.
566 -- In this version, we check if the task is held too because
567 -- doing this only in Do_Pending_Action is not enough.
569 procedure Poll_Base_Priority_Change (Self_ID : Task_Id) is
571 if Dynamic_Priority_Support and then Self_ID.Pending_Priority_Change then
573 -- Check for ceiling violations ???
575 Self_ID.Pending_Priority_Change := False;
577 if Self_ID.Common.Base_Priority = Self_ID.New_Base_Priority then
585 Write_Lock (Self_ID);
588 elsif Self_ID.Common.Base_Priority < Self_ID.New_Base_Priority then
589 Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority;
590 Set_Priority (Self_ID, Self_ID.Common.Base_Priority);
595 Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority;
596 Set_Priority (Self_ID, Self_ID.Common.Base_Priority);
605 Write_Lock (Self_ID);
609 end Poll_Base_Priority_Change;
611 --------------------------------
612 -- Remove_From_All_Tasks_List --
613 --------------------------------
615 procedure Remove_From_All_Tasks_List (T : Task_Id) is
621 (Debug.Trace (Self, "Remove_From_All_Tasks_List", 'C'));
623 Previous := Null_Task;
626 while C /= Null_Task loop
628 if Previous = Null_Task then
630 All_Tasks_List.Common.All_Tasks_Link;
632 Previous.Common.All_Tasks_Link := C.Common.All_Tasks_Link;
639 C := C.Common.All_Tasks_Link;
642 pragma Assert (False);
643 end Remove_From_All_Tasks_List;
649 procedure Task_Lock (Self_ID : Task_Id) is
651 Self_ID.Global_Task_Lock_Nesting := Self_ID.Global_Task_Lock_Nesting + 1;
653 if Self_ID.Global_Task_Lock_Nesting = 1 then
654 Defer_Abort_Nestable (Self_ID);
655 Write_Lock (Global_Task_Lock'Access, Global_Lock => True);
659 procedure Task_Lock is
661 Task_Lock (STPO.Self);
668 function Task_Name return String is
669 Self_Id : constant Task_Id := STPO.Self;
672 return Self_Id.Common.Task_Image (1 .. Self_Id.Common.Task_Image_Len);
679 procedure Task_Unlock (Self_ID : Task_Id) is
681 pragma Assert (Self_ID.Global_Task_Lock_Nesting > 0);
682 Self_ID.Global_Task_Lock_Nesting := Self_ID.Global_Task_Lock_Nesting - 1;
684 if Self_ID.Global_Task_Lock_Nesting = 0 then
685 Unlock (Global_Task_Lock'Access, Global_Lock => True);
686 Undefer_Abort_Nestable (Self_ID);
690 procedure Task_Unlock is
692 Task_Unlock (STPO.Self);
699 -- Precondition : Self does not hold any locks!
701 -- Undefer_Abort is called on any abortion completion point (aka.
702 -- synchronization point). It performs the following actions if they
703 -- are pending: (1) change the base priority, (2) abort the task.
705 -- The priority change has to occur before abortion. Otherwise, it would
706 -- take effect no earlier than the next abortion completion point.
708 procedure Undefer_Abort (Self_ID : Task_Id) is
710 if No_Abort and then not Dynamic_Priority_Support then
714 pragma Assert (Self_ID.Deferral_Level = 1);
716 Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1;
718 if Self_ID.Deferral_Level = 0 then
719 pragma Assert (Check_No_Locks (Self_ID));
721 if Self_ID.Pending_Action then
722 Do_Pending_Action (Self_ID);
727 ----------------------------
728 -- Undefer_Abort_Nestable --
729 ----------------------------
731 -- An earlier version would re-defer abort if an abort is in progress.
732 -- Then, we modified the effect of the raise statement so that it defers
733 -- abort until control reaches a handler. That was done to prevent
734 -- "skipping over" a handler if another asynchronous abort occurs during
735 -- the propagation of the abort to the handler.
737 -- There has been talk of reversing that decision, based on a newer
738 -- implementation of exception propagation. Care must be taken to evaluate
739 -- how such a change would interact with the above code and all the places
740 -- where abort-deferral is used to bridge over critical transitions, such
741 -- as entry to the scope of a region with a finalizer and entry into the
742 -- body of an accept-procedure.
744 procedure Undefer_Abort_Nestable (Self_ID : Task_Id) is
746 if No_Abort and then not Dynamic_Priority_Support then
750 pragma Assert (Self_ID.Deferral_Level > 0);
752 Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1;
754 if Self_ID.Deferral_Level = 0 then
756 pragma Assert (Check_No_Locks (Self_ID));
758 if Self_ID.Pending_Action then
759 Do_Pending_Action (Self_ID);
762 end Undefer_Abort_Nestable;
764 ----------------------
765 -- Undefer_Abortion --
766 ----------------------
768 -- Phase out RTS-internal use of Undefer_Abortion
769 -- to reduce overhead due to multiple calls to Self.
771 procedure Undefer_Abortion is
775 if No_Abort and then not Dynamic_Priority_Support then
779 Self_ID := STPO.Self;
780 pragma Assert (Self_ID.Deferral_Level > 0);
782 Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1;
784 if Self_ID.Deferral_Level = 0 then
785 pragma Assert (Check_No_Locks (Self_ID));
787 if Self_ID.Pending_Action then
788 Do_Pending_Action (Self_ID);
791 end Undefer_Abortion;
793 ----------------------
794 -- Update_Exception --
795 ----------------------
797 -- Call only when holding no locks.
799 procedure Update_Exception
800 (X : AE.Exception_Occurrence := Current_Target_Exception)
802 Self_Id : constant Task_Id := Self;
806 Save_Occurrence (Self_Id.Common.Compiler_Data.Current_Excep, X);
808 if Self_Id.Deferral_Level = 0 then
809 if Self_Id.Pending_Action then
810 Self_Id.Pending_Action := False;
811 Self_Id.Deferral_Level := Self_Id.Deferral_Level + 1;
817 Write_Lock (Self_Id);
818 Self_Id.Pending_Action := False;
819 Poll_Base_Priority_Change (Self_Id);
826 Self_Id.Deferral_Level := Self_Id.Deferral_Level - 1;
828 if Self_Id.Pending_ATC_Level < Self_Id.ATC_Nesting_Level then
829 if not Self_Id.Aborting then
830 Self_Id.Aborting := True;
831 raise Standard'Abort_Signal;
836 end Update_Exception;
838 --------------------------
839 -- Wakeup_Entry_Caller --
840 --------------------------
842 -- This is called at the end of service of an entry call, to abort the
843 -- caller if he is in an abortable part, and to wake up the caller if it
844 -- is on Entry_Caller_Sleep. It assumes that the call is already off-queue.
846 -- (This enforces the rule that a task must be off-queue if its state is
847 -- Done or Cancelled.) Call it holding the lock of Entry_Call.Self.
849 -- Timed_Call or Simple_Call:
850 -- The caller is waiting on Entry_Caller_Sleep, in
851 -- Wait_For_Completion, or Wait_For_Completion_With_Timeout.
854 -- The caller might be in Wait_For_Completion,
855 -- waiting for a rendezvous (possibly requeued without abort)
858 -- Asynchronous_Call:
859 -- The caller may be executing in the abortable part o
860 -- an async. select, or on a time delay,
861 -- if Entry_Call.State >= Was_Abortable.
863 procedure Wakeup_Entry_Caller
865 Entry_Call : Entry_Call_Link;
866 New_State : Entry_Call_State)
868 Caller : constant Task_Id := Entry_Call.Self;
871 pragma Debug (Debug.Trace
872 (Self_ID, "Wakeup_Entry_Caller", 'E', Caller));
873 pragma Assert (New_State = Done or else New_State = Cancelled);
876 (Caller.Common.State /= Terminated
877 and then Caller.Common.State /= Unactivated);
879 Entry_Call.State := New_State;
881 if Entry_Call.Mode = Asynchronous_Call then
883 -- Abort the caller in his abortable part,
884 -- but do so only if call has been queued abortably
886 if Entry_Call.State >= Was_Abortable or else New_State = Done then
887 Locked_Abort_To_Level (Self_ID, Caller, Entry_Call.Level - 1);
890 elsif Caller.Common.State = Entry_Caller_Sleep then
891 Wakeup (Caller, Entry_Caller_Sleep);
893 end Wakeup_Entry_Caller;
895 ----------------------
896 -- Soft-Link Bodies --
897 ----------------------
899 function Get_Exc_Stack_Addr return Address is
901 return STPO.Self.Common.Compiler_Data.Exc_Stack_Addr;
902 end Get_Exc_Stack_Addr;
904 function Get_Stack_Info return Stack_Checking.Stack_Access is
906 return STPO.Self.Common.Compiler_Data.Pri_Stack_Info'Access;
909 procedure Set_Exc_Stack_Addr (Self_ID : Address; Addr : Address) is
910 Me : Task_Id := To_Task_Id (Self_ID);
912 if Me = Null_Task then
916 Me.Common.Compiler_Data.Exc_Stack_Addr := Addr;
917 end Set_Exc_Stack_Addr;
919 -----------------------
920 -- Soft-Link Dummies --
921 -----------------------
923 -- These are dummies for subprograms that are only needed by certain
924 -- optional run-time system packages. If they are needed, the soft
925 -- links will be redirected to the real subprogram by elaboration of
926 -- the subprogram body where the real subprogram is declared.
928 procedure Finalize_Attributes (T : Task_Id) is
929 pragma Warnings (Off, T);
933 end Finalize_Attributes;
935 procedure Initialize_Attributes (T : Task_Id) is
936 pragma Warnings (Off, T);
940 end Initialize_Attributes;
944 end System.Tasking.Initialization;