1 ------------------------------------------------------------------------------
3 -- GNAT 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-2005, 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 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
46 with System
.Task_Primitives
;
49 with System
.Task_Primitives
.Operations
;
50 -- Used for Set_Priority
55 with System
.Soft_Links
;
56 -- Used for the non-tasking routines (*_NT) that refer to global data.
57 -- They are needed here before the tasking run time has been elaborated.
59 with System
.Soft_Links
.Tasking
;
60 -- Used for Init_Tasking_Soft_Links
62 with System
.Tasking
.Debug
;
65 with System
.Stack_Checking
;
67 with System
.Parameters
;
68 -- used for Single_Lock
70 package body System
.Tasking
.Initialization
is
72 package STPO
renames System
.Task_Primitives
.Operations
;
73 package SSL
renames System
.Soft_Links
;
74 package AE
renames Ada
.Exceptions
;
77 use Task_Primitives
.Operations
;
79 Global_Task_Lock
: aliased System
.Task_Primitives
.RTS_Lock
;
80 -- This is a global lock; it is used to execute in mutual exclusion
81 -- from all other tasks. It is only used by Task_Lock,
82 -- Task_Unlock, and Final_Task_Unlock.
84 function Current_Target_Exception
return AE
.Exception_Occurrence
;
86 (Ada
, Current_Target_Exception
, "__gnat_current_target_exception");
87 -- Import this subprogram from the private part of Ada.Exceptions
89 ----------------------------------------------------------------------
90 -- Tasking versions of some services needed by non-tasking programs --
91 ----------------------------------------------------------------------
93 procedure Abort_Defer
;
94 -- NON-INLINE versions without Self_ID for soft links
96 procedure Abort_Undefer
;
97 -- NON-INLINE versions without Self_ID for soft links
100 -- Locks out other tasks. Preceding a section of code by Task_Lock and
101 -- following it by Task_Unlock creates a critical region. This is used
102 -- for ensuring that a region of non-tasking code (such as code used to
103 -- allocate memory) is tasking safe. Note that it is valid for calls to
104 -- Task_Lock/Task_Unlock to be nested, and this must work properly, i.e.
105 -- only the corresponding outer level Task_Unlock will actually unlock.
107 procedure Task_Unlock
;
108 -- Releases lock previously set by call to Task_Lock. In the nested case,
109 -- all nested locks must be released before other tasks competing for the
110 -- tasking lock are released.
112 function Get_Stack_Info
return Stack_Checking
.Stack_Access
;
113 -- Get access to the current task's Stack_Info
115 procedure Update_Exception
116 (X
: AE
.Exception_Occurrence
:= Current_Target_Exception
);
117 -- Handle exception setting and check for pending actions
119 function Task_Name
return String;
120 -- Returns current task's name
122 ------------------------
123 -- Local Subprograms --
124 ------------------------
126 ----------------------------
127 -- Tasking Initialization --
128 ----------------------------
131 -- This procedure completes the initialization of the GNARL. The first
132 -- part of the initialization is done in the body of System.Tasking.
133 -- It consists of initializing global locks, and installing tasking
134 -- versions of certain operations used by the compiler. Init_RTS is called
135 -- during elaboration.
137 --------------------------
138 -- Change_Base_Priority --
139 --------------------------
141 -- Call only with abort deferred and holding Self_ID locked
143 procedure Change_Base_Priority
(T
: Task_Id
) is
145 if T
.Common
.Base_Priority
/= T
.New_Base_Priority
then
146 T
.Common
.Base_Priority
:= T
.New_Base_Priority
;
147 Set_Priority
(T
, T
.Common
.Base_Priority
);
149 end Change_Base_Priority
;
151 ------------------------
152 -- Check_Abort_Status --
153 ------------------------
155 function Check_Abort_Status
return Integer is
156 Self_ID
: constant Task_Id
:= Self
;
158 if Self_ID
/= null and then Self_ID
.Deferral_Level
= 0
159 and then Self_ID
.Pending_ATC_Level
< Self_ID
.ATC_Nesting_Level
165 end Check_Abort_Status
;
171 procedure Defer_Abort
(Self_ID
: Task_Id
) is
173 if No_Abort
and then not Dynamic_Priority_Support
then
177 pragma Assert
(Self_ID
.Deferral_Level
= 0);
180 -- (Self_ID.Pending_ATC_Level >= Self_ID.ATC_Nesting_Level);
182 -- The above check has been useful in detecting mismatched defer/undefer
183 -- pairs. You may uncomment it when testing on systems that support
186 -- If the OS supports preemptive abort (e.g. pthread_kill), it should
187 -- have happened already. A problem is with systems that do not support
188 -- preemptive abort, and so rely on polling. On such systems we may get
189 -- false failures of the assertion, since polling for pending abort does
190 -- no occur until the abort undefer operation.
192 -- Even on systems that only poll for abort, the assertion may be useful
193 -- for catching missed abort completion polling points. The operations
194 -- that undefer abort poll for pending aborts. This covers most of the
195 -- places where the core Ada semantics require abort to be caught,
196 -- without any special attention. However, this generally happens on
197 -- exit from runtime system call, which means a pending abort will not
198 -- be noticed on the way into the runtime system. We considered adding a
199 -- check for pending aborts at this point, but chose not to, because of
200 -- the overhead. Instead, we searched for RTS calls where abort
201 -- completion is required and a task could go farther than Ada allows
202 -- before undeferring abort; we then modified the code to ensure the
203 -- abort would be detected.
205 Self_ID
.Deferral_Level
:= Self_ID
.Deferral_Level
+ 1;
208 --------------------------
209 -- Defer_Abort_Nestable --
210 --------------------------
212 procedure Defer_Abort_Nestable
(Self_ID
: Task_Id
) is
214 if No_Abort
and then not Dynamic_Priority_Support
then
219 -- ((Self_ID.Pending_ATC_Level >= Self_ID.ATC_Nesting_Level or else
220 -- Self_ID.Deferral_Level > 0));
222 -- See comment in Defer_Abort on the situations in which it may be
223 -- useful to uncomment the above assertion.
225 Self_ID
.Deferral_Level
:= Self_ID
.Deferral_Level
+ 1;
226 end Defer_Abort_Nestable
;
232 procedure Abort_Defer
is
235 if No_Abort
and then not Dynamic_Priority_Support
then
239 Self_ID
:= STPO
.Self
;
240 Self_ID
.Deferral_Level
:= Self_ID
.Deferral_Level
+ 1;
243 -----------------------
244 -- Do_Pending_Action --
245 -----------------------
247 -- Call only when holding no locks
249 procedure Do_Pending_Action
(Self_ID
: Task_Id
) is
250 use type Ada
.Exceptions
.Exception_Id
;
253 pragma Assert
(Self_ID
= Self
and then Self_ID
.Deferral_Level
= 0);
255 -- Needs loop to recheck for pending action in case a new one occurred
256 -- while we had abort deferred below.
259 -- Temporarily defer abort so that we can lock Self_ID
261 Self_ID
.Deferral_Level
:= Self_ID
.Deferral_Level
+ 1;
267 Write_Lock
(Self_ID
);
268 Self_ID
.Pending_Action
:= False;
269 Poll_Base_Priority_Change
(Self_ID
);
276 -- Restore the original Deferral value
278 Self_ID
.Deferral_Level
:= Self_ID
.Deferral_Level
- 1;
280 if not Self_ID
.Pending_Action
then
281 if Self_ID
.Pending_ATC_Level
< Self_ID
.ATC_Nesting_Level
then
282 if not Self_ID
.Aborting
then
283 Self_ID
.Aborting
:= True;
285 (Debug
.Trace
(Self_ID
, "raise Abort_Signal", 'B'));
286 raise Standard
'Abort_Signal;
288 pragma Assert
(not Self_ID
.ATC_Hack
);
290 elsif Self_ID
.ATC_Hack
then
291 -- The solution really belongs in the Abort_Signal handler
292 -- for async. entry calls. The present hack is very
293 -- fragile. It relies that the very next point after
294 -- Exit_One_ATC_Level at which the task becomes abortable
295 -- will be the call to Undefer_Abort in the
296 -- Abort_Signal handler.
298 Self_ID
.ATC_Hack
:= False;
302 (Self_ID
, "raise Abort_Signal (ATC hack)", 'B'));
303 raise Standard
'Abort_Signal;
310 end Do_Pending_Action
;
312 -----------------------
313 -- Final_Task_Unlock --
314 -----------------------
316 -- This version is only for use in Terminate_Task, when the task
317 -- is relinquishing further rights to its own ATCB.
318 -- There is a very interesting potential race condition there, where
319 -- the old task may run concurrently with a new task that is allocated
320 -- the old tasks (now reused) ATCB. The critical thing here is to
321 -- not make any reference to the ATCB after the lock is released.
322 -- See also comments on Terminate_Task and Unlock.
324 procedure Final_Task_Unlock
(Self_ID
: Task_Id
) is
326 pragma Assert
(Self_ID
.Common
.Global_Task_Lock_Nesting
= 1);
327 Unlock
(Global_Task_Lock
'Access, Global_Lock
=> True);
328 end Final_Task_Unlock
;
334 procedure Init_RTS
is
339 -- Terminate run time (regular vs restricted) specific initialization
340 -- of the environment task.
342 Self_Id
:= Environment_Task
;
343 Self_Id
.Master_of_Task
:= Environment_Task_Level
;
344 Self_Id
.Master_Within
:= Self_Id
.Master_of_Task
+ 1;
346 for L
in Self_Id
.Entry_Calls
'Range loop
347 Self_Id
.Entry_Calls
(L
).Self
:= Self_Id
;
348 Self_Id
.Entry_Calls
(L
).Level
:= L
;
351 Self_Id
.Awake_Count
:= 1;
352 Self_Id
.Alive_Count
:= 1;
354 Self_Id
.Master_Within
:= Library_Task_Level
;
355 -- Normally, a task starts out with internal master nesting level
356 -- one larger than external master nesting level. It is incremented
357 -- to one by Enter_Master, which is called in the task body only if
358 -- the compiler thinks the task may have dependent tasks. There is no
359 -- corresponding call to Enter_Master for the environment task, so we
360 -- would need to increment it to 2 here. Instead, we set it to 3.
361 -- By doing this we reserve the level 2 for server tasks of the runtime
362 -- system. The environment task does not need to wait for these server
364 -- Initialize lock used to implement mutual exclusion between all tasks
366 Initialize_Lock
(Global_Task_Lock
'Access, STPO
.Global_Task_Level
);
368 -- Notify that the tasking run time has been elaborated so that
369 -- the tasking version of the soft links can be used.
371 if not No_Abort
or else Dynamic_Priority_Support
then
372 SSL
.Abort_Defer
:= Abort_Defer
'Access;
373 SSL
.Abort_Undefer
:= Abort_Undefer
'Access;
376 SSL
.Update_Exception
:= Update_Exception
'Access;
377 SSL
.Lock_Task
:= Task_Lock
'Access;
378 SSL
.Unlock_Task
:= Task_Unlock
'Access;
379 SSL
.Check_Abort_Status
:= Check_Abort_Status
'Access;
380 SSL
.Get_Stack_Info
:= Get_Stack_Info
'Access;
381 SSL
.Task_Name
:= Task_Name
'Access;
383 -- Initialize the tasking soft links (if not done yet) that are common
384 -- to the full and the restricted run times.
386 SSL
.Tasking
.Init_Tasking_Soft_Links
;
388 -- Abort is deferred in a new ATCB, so we need to undefer abort
389 -- at this stage to make the environment task abortable.
391 Undefer_Abort
(Environment_Task
);
394 ---------------------------
395 -- Locked_Abort_To_Level--
396 ---------------------------
398 -- Abort a task to the specified ATC nesting level.
399 -- Call this only with T locked.
401 -- An earlier version of this code contained a call to Wakeup. That
402 -- should not be necessary here, if Abort_Task is implemented correctly,
403 -- since Abort_Task should include the effect of Wakeup. However, the
404 -- above call was in earlier versions of this file, and at least for
405 -- some targets Abort_Task has not beek doing Wakeup. It should not
406 -- hurt to uncomment the above call, until the error is corrected for
409 -- See extended comments in package body System.Tasking.Abort for the
410 -- overall design of the implementation of task abort.
411 -- ??? there is no such package ???
413 -- If the task is sleeping it will be in an abort-deferred region, and
414 -- will not have Abort_Signal raised by Abort_Task. Such an "abort
415 -- deferral" is just to protect the RTS internals, and not necessarily
416 -- required to enforce Ada semantics. Abort_Task should wake the task up
417 -- and let it decide if it wants to complete the aborted construct
420 -- Note that the effect of the lowl-level Abort_Task is not persistent.
421 -- If the target task is not blocked, this wakeup will be missed.
423 -- We don't bother calling Abort_Task if this task is aborting itself,
424 -- since we are inside the RTS and have abort deferred. Similarly, We
425 -- don't bother to call Abort_Task if T is terminated, since there is
426 -- no need to abort a terminated task, and it could be dangerous to try
427 -- if the task has stopped executing.
429 -- Note that an earlier version of this code had some false reasoning
430 -- about being able to reliably wake up a task that had suspended on
431 -- a blocking system call that does not atomically relase the task's
432 -- lock (e.g., UNIX nanosleep, which we once thought could be used to
433 -- implement delays). That still left the possibility of missed
436 -- We cannot safely call Vulnerable_Complete_Activation here, since that
437 -- requires locking Self_ID.Parent. The anti-deadlock lock ordering rules
438 -- would then require us to release the lock on Self_ID first, which would
439 -- create a timing window for other tasks to lock Self_ID. This is
440 -- significant for tasks that may be aborted before their execution can
441 -- enter the task body, and so they do not get a chance to call
442 -- Complete_Task. The actual work for this case is done in Terminate_Task.
444 procedure Locked_Abort_To_Level
450 if not T
.Aborting
and then T
/= Self_ID
then
451 case T
.Common
.State
is
452 when Unactivated | Terminated
=>
453 pragma Assert
(False);
457 -- This is needed to cancel an asynchronous protected entry
458 -- call during a requeue with abort.
461 (T
.ATC_Nesting_Level
).Cancellation_Attempted
:= True;
463 when Interrupt_Server_Blocked_On_Event_Flag
=>
468 Interrupt_Server_Idle_Sleep |
469 Interrupt_Server_Blocked_Interrupt_Sleep |
472 Wakeup
(T
, T
.Common
.State
);
474 when Acceptor_Sleep
=>
475 T
.Open_Accepts
:= null;
476 Wakeup
(T
, T
.Common
.State
);
478 when Entry_Caller_Sleep
=>
480 (T
.ATC_Nesting_Level
).Cancellation_Attempted
:= True;
481 Wakeup
(T
, T
.Common
.State
);
483 when Activator_Sleep |
484 Master_Completion_Sleep |
485 Master_Phase_2_Sleep |
491 if T
.Pending_ATC_Level
> L
then
492 T
.Pending_ATC_Level
:= L
;
493 T
.Pending_Action
:= True;
499 -- This prevents aborted task from accepting calls
503 -- The test above is just a heuristic, to reduce wasteful
504 -- calls to Abort_Task. We are holding T locked, and this
505 -- value will not be set to False except with T also locked,
506 -- inside Exit_One_ATC_Level, so we should not miss wakeups.
508 if T
.Common
.State
= Acceptor_Sleep
then
509 T
.Open_Accepts
:= null;
512 elsif T
/= Self_ID
and then
513 (T
.Common
.State
= Runnable
514 or else T
.Common
.State
= Interrupt_Server_Blocked_On_Event_Flag
)
515 -- The task is blocked on a system call waiting for the
516 -- completion event. In this case Abort_Task may need to take
517 -- special action in order to succeed. Example system: VMS.
523 end Locked_Abort_To_Level
;
525 -------------------------------
526 -- Poll_Base_Priority_Change --
527 -------------------------------
529 -- Poll for pending base priority change and for held tasks.
530 -- This should always be called with (only) Self_ID locked.
531 -- It may temporarily release Self_ID's lock.
533 -- The call to Yield is to force enqueuing at the
534 -- tail of the dispatching queue.
536 -- We must unlock Self_ID for this to take effect,
537 -- since we are inheriting high active priority from the lock.
539 -- See also Poll_Base_Priority_Change_At_Entry_Call,
540 -- in package System.Tasking.Entry_Calls.
542 -- In this version, we check if the task is held too because
543 -- doing this only in Do_Pending_Action is not enough.
545 procedure Poll_Base_Priority_Change
(Self_ID
: Task_Id
) is
547 if Dynamic_Priority_Support
and then Self_ID
.Pending_Priority_Change
then
549 -- Check for ceiling violations ???
551 Self_ID
.Pending_Priority_Change
:= False;
553 if Self_ID
.Common
.Base_Priority
= Self_ID
.New_Base_Priority
then
561 Write_Lock
(Self_ID
);
564 elsif Self_ID
.Common
.Base_Priority
< Self_ID
.New_Base_Priority
then
565 Self_ID
.Common
.Base_Priority
:= Self_ID
.New_Base_Priority
;
566 Set_Priority
(Self_ID
, Self_ID
.Common
.Base_Priority
);
571 Self_ID
.Common
.Base_Priority
:= Self_ID
.New_Base_Priority
;
572 Set_Priority
(Self_ID
, Self_ID
.Common
.Base_Priority
);
581 Write_Lock
(Self_ID
);
585 end Poll_Base_Priority_Change
;
587 --------------------------------
588 -- Remove_From_All_Tasks_List --
589 --------------------------------
591 procedure Remove_From_All_Tasks_List
(T
: Task_Id
) is
597 (Debug
.Trace
(Self
, "Remove_From_All_Tasks_List", 'C'));
599 Previous
:= Null_Task
;
602 while C
/= Null_Task
loop
604 if Previous
= Null_Task
then
606 All_Tasks_List
.Common
.All_Tasks_Link
;
608 Previous
.Common
.All_Tasks_Link
:= C
.Common
.All_Tasks_Link
;
615 C
:= C
.Common
.All_Tasks_Link
;
618 pragma Assert
(False);
619 end Remove_From_All_Tasks_List
;
625 procedure Task_Lock
(Self_ID
: Task_Id
) is
627 Self_ID
.Common
.Global_Task_Lock_Nesting
:=
628 Self_ID
.Common
.Global_Task_Lock_Nesting
+ 1;
630 if Self_ID
.Common
.Global_Task_Lock_Nesting
= 1 then
631 Defer_Abort_Nestable
(Self_ID
);
632 Write_Lock
(Global_Task_Lock
'Access, Global_Lock
=> True);
636 procedure Task_Lock
is
638 Task_Lock
(STPO
.Self
);
645 function Task_Name
return String is
646 Self_Id
: constant Task_Id
:= STPO
.Self
;
649 return Self_Id
.Common
.Task_Image
(1 .. Self_Id
.Common
.Task_Image_Len
);
656 procedure Task_Unlock
(Self_ID
: Task_Id
) is
658 pragma Assert
(Self_ID
.Common
.Global_Task_Lock_Nesting
> 0);
659 Self_ID
.Common
.Global_Task_Lock_Nesting
:=
660 Self_ID
.Common
.Global_Task_Lock_Nesting
- 1;
662 if Self_ID
.Common
.Global_Task_Lock_Nesting
= 0 then
663 Unlock
(Global_Task_Lock
'Access, Global_Lock
=> True);
664 Undefer_Abort_Nestable
(Self_ID
);
668 procedure Task_Unlock
is
670 Task_Unlock
(STPO
.Self
);
677 -- Precondition : Self does not hold any locks!
679 -- Undefer_Abort is called on any abort completion point (aka.
680 -- synchronization point). It performs the following actions if they
681 -- are pending: (1) change the base priority, (2) abort the task.
683 -- The priority change has to occur before abort. Otherwise, it would
684 -- take effect no earlier than the next abort completion point.
686 procedure Undefer_Abort
(Self_ID
: Task_Id
) is
688 if No_Abort
and then not Dynamic_Priority_Support
then
692 pragma Assert
(Self_ID
.Deferral_Level
= 1);
694 Self_ID
.Deferral_Level
:= Self_ID
.Deferral_Level
- 1;
696 if Self_ID
.Deferral_Level
= 0 then
697 pragma Assert
(Check_No_Locks
(Self_ID
));
699 if Self_ID
.Pending_Action
then
700 Do_Pending_Action
(Self_ID
);
705 ----------------------------
706 -- Undefer_Abort_Nestable --
707 ----------------------------
709 -- An earlier version would re-defer abort if an abort is in progress.
710 -- Then, we modified the effect of the raise statement so that it defers
711 -- abort until control reaches a handler. That was done to prevent
712 -- "skipping over" a handler if another asynchronous abort occurs during
713 -- the propagation of the abort to the handler.
715 -- There has been talk of reversing that decision, based on a newer
716 -- implementation of exception propagation. Care must be taken to evaluate
717 -- how such a change would interact with the above code and all the places
718 -- where abort-deferral is used to bridge over critical transitions, such
719 -- as entry to the scope of a region with a finalizer and entry into the
720 -- body of an accept-procedure.
722 procedure Undefer_Abort_Nestable
(Self_ID
: Task_Id
) is
724 if No_Abort
and then not Dynamic_Priority_Support
then
728 pragma Assert
(Self_ID
.Deferral_Level
> 0);
730 Self_ID
.Deferral_Level
:= Self_ID
.Deferral_Level
- 1;
732 if Self_ID
.Deferral_Level
= 0 then
734 pragma Assert
(Check_No_Locks
(Self_ID
));
736 if Self_ID
.Pending_Action
then
737 Do_Pending_Action
(Self_ID
);
740 end Undefer_Abort_Nestable
;
746 procedure Abort_Undefer
is
749 if No_Abort
and then not Dynamic_Priority_Support
then
753 Self_ID
:= STPO
.Self
;
755 if Self_ID
.Deferral_Level
= 0 then
757 -- In case there are different views on whether Abort is supported
758 -- between the expander and the run time, we may end up with
759 -- Self_ID.Deferral_Level being equal to zero, when called from
760 -- the procedure created by the expander that corresponds to a
763 -- In this case, there's nothing to be done
765 -- See related code in System.Tasking.Stages.Create_Task resetting
766 -- Deferral_Level when System.Restrictions.Abort_Allowed is False.
771 pragma Assert
(Self_ID
.Deferral_Level
> 0);
772 Self_ID
.Deferral_Level
:= Self_ID
.Deferral_Level
- 1;
774 if Self_ID
.Deferral_Level
= 0 then
775 pragma Assert
(Check_No_Locks
(Self_ID
));
777 if Self_ID
.Pending_Action
then
778 Do_Pending_Action
(Self_ID
);
783 ----------------------
784 -- Update_Exception --
785 ----------------------
787 -- Call only when holding no locks
789 procedure Update_Exception
790 (X
: AE
.Exception_Occurrence
:= Current_Target_Exception
)
792 Self_Id
: constant Task_Id
:= Self
;
796 Save_Occurrence
(Self_Id
.Common
.Compiler_Data
.Current_Excep
, X
);
798 if Self_Id
.Deferral_Level
= 0 then
799 if Self_Id
.Pending_Action
then
800 Self_Id
.Pending_Action
:= False;
801 Self_Id
.Deferral_Level
:= Self_Id
.Deferral_Level
+ 1;
807 Write_Lock
(Self_Id
);
808 Self_Id
.Pending_Action
:= False;
809 Poll_Base_Priority_Change
(Self_Id
);
816 Self_Id
.Deferral_Level
:= Self_Id
.Deferral_Level
- 1;
818 if Self_Id
.Pending_ATC_Level
< Self_Id
.ATC_Nesting_Level
then
819 if not Self_Id
.Aborting
then
820 Self_Id
.Aborting
:= True;
821 raise Standard
'Abort_Signal;
826 end Update_Exception
;
828 --------------------------
829 -- Wakeup_Entry_Caller --
830 --------------------------
832 -- This is called at the end of service of an entry call, to abort the
833 -- caller if he is in an abortable part, and to wake up the caller if it
834 -- is on Entry_Caller_Sleep. It assumes that the call is already off-queue.
836 -- (This enforces the rule that a task must be off-queue if its state is
837 -- Done or Cancelled.) Call it holding the lock of Entry_Call.Self.
839 -- Timed_Call or Simple_Call:
840 -- The caller is waiting on Entry_Caller_Sleep, in
841 -- Wait_For_Completion, or Wait_For_Completion_With_Timeout.
844 -- The caller might be in Wait_For_Completion,
845 -- waiting for a rendezvous (possibly requeued without abort)
848 -- Asynchronous_Call:
849 -- The caller may be executing in the abortable part o
850 -- an async. select, or on a time delay,
851 -- if Entry_Call.State >= Was_Abortable.
853 procedure Wakeup_Entry_Caller
855 Entry_Call
: Entry_Call_Link
;
856 New_State
: Entry_Call_State
)
858 Caller
: constant Task_Id
:= Entry_Call
.Self
;
861 pragma Debug
(Debug
.Trace
862 (Self_ID
, "Wakeup_Entry_Caller", 'E', Caller
));
863 pragma Assert
(New_State
= Done
or else New_State
= Cancelled
);
866 (Caller
.Common
.State
/= Terminated
867 and then Caller
.Common
.State
/= Unactivated
);
869 Entry_Call
.State
:= New_State
;
871 if Entry_Call
.Mode
= Asynchronous_Call
then
873 -- Abort the caller in his abortable part,
874 -- but do so only if call has been queued abortably
876 if Entry_Call
.State
>= Was_Abortable
or else New_State
= Done
then
877 Locked_Abort_To_Level
(Self_ID
, Caller
, Entry_Call
.Level
- 1);
880 elsif Caller
.Common
.State
= Entry_Caller_Sleep
then
881 Wakeup
(Caller
, Entry_Caller_Sleep
);
883 end Wakeup_Entry_Caller
;
885 ----------------------
886 -- Soft-Link Bodies --
887 ----------------------
889 function Get_Stack_Info
return Stack_Checking
.Stack_Access
is
891 return STPO
.Self
.Common
.Compiler_Data
.Pri_Stack_Info
'Access;
894 -----------------------
895 -- Soft-Link Dummies --
896 -----------------------
898 -- These are dummies for subprograms that are only needed by certain
899 -- optional run-time system packages. If they are needed, the soft
900 -- links will be redirected to the real subprogram by elaboration of
901 -- the subprogram body where the real subprogram is declared.
903 procedure Finalize_Attributes
(T
: Task_Id
) is
904 pragma Warnings
(Off
, T
);
908 end Finalize_Attributes
;
910 procedure Initialize_Attributes
(T
: Task_Id
) is
911 pragma Warnings
(Off
, T
);
915 end Initialize_Attributes
;
919 end System
.Tasking
.Initialization
;