objc-act.c (synth_module_prologue): Use TREE_NO_WARNING instead of DECL_IN_SYSTEM_HEADER.
[official-gcc.git] / gcc / ada / s-tasini.adb
blob6719cc0539546238b76a38de09f1e6f25e5c43a3
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
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 --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
10 -- --
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. --
21 -- --
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. --
28 -- --
29 -- GNARL was developed by the GNARL team at Florida State University. --
30 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 pragma Style_Checks (All_Checks);
35 -- Turn off subprogram alpha ordering check, since we group soft link bodies
36 -- and dummy soft link bodies together separately in this unit.
38 pragma Polling (Off);
39 -- Turn polling off for this package. We don't need polling during any of the
40 -- routines in this package, and more to the point, if we try to poll it can
41 -- cause infinite loops.
43 with Ada.Exceptions;
45 with System.Task_Primitives;
46 with System.Task_Primitives.Operations;
47 with System.Soft_Links;
48 with System.Soft_Links.Tasking;
49 with System.Tasking.Debug;
50 with System.Parameters;
52 package body System.Tasking.Initialization is
54 package STPO renames System.Task_Primitives.Operations;
55 package SSL renames System.Soft_Links;
56 package AE renames Ada.Exceptions;
58 use Parameters;
59 use Task_Primitives.Operations;
61 Global_Task_Lock : aliased System.Task_Primitives.RTS_Lock;
62 -- This is a global lock; it is used to execute in mutual exclusion
63 -- from all other tasks. It is only used by Task_Lock,
64 -- Task_Unlock, and Final_Task_Unlock.
66 ----------------------------------------------------------------------
67 -- Tasking versions of some services needed by non-tasking programs --
68 ----------------------------------------------------------------------
70 procedure Abort_Defer;
71 -- NON-INLINE versions without Self_ID for soft links
73 procedure Abort_Undefer;
74 -- NON-INLINE versions without Self_ID for soft links
76 procedure Task_Lock;
77 -- Locks out other tasks. Preceding a section of code by Task_Lock and
78 -- following it by Task_Unlock creates a critical region. This is used
79 -- for ensuring that a region of non-tasking code (such as code used to
80 -- allocate memory) is tasking safe. Note that it is valid for calls to
81 -- Task_Lock/Task_Unlock to be nested, and this must work properly, i.e.
82 -- only the corresponding outer level Task_Unlock will actually unlock.
84 procedure Task_Unlock;
85 -- Releases lock previously set by call to Task_Lock. In the nested case,
86 -- all nested locks must be released before other tasks competing for the
87 -- tasking lock are released.
89 function Get_Current_Excep return SSL.EOA;
90 -- Task-safe version of SSL.Get_Current_Excep
92 procedure Update_Exception
93 (X : AE.Exception_Occurrence := SSL.Current_Target_Exception);
94 -- Handle exception setting and check for pending actions
96 function Task_Name return String;
97 -- Returns current task's name
99 ------------------------
100 -- Local Subprograms --
101 ------------------------
103 ----------------------------
104 -- Tasking Initialization --
105 ----------------------------
107 procedure Init_RTS;
108 -- This procedure completes the initialization of the GNARL. The first
109 -- part of the initialization is done in the body of System.Tasking.
110 -- It consists of initializing global locks, and installing tasking
111 -- versions of certain operations used by the compiler. Init_RTS is called
112 -- during elaboration.
114 --------------------------
115 -- Change_Base_Priority --
116 --------------------------
118 -- Call only with abort deferred and holding Self_ID locked
120 procedure Change_Base_Priority (T : Task_Id) is
121 begin
122 if T.Common.Base_Priority /= T.New_Base_Priority then
123 T.Common.Base_Priority := T.New_Base_Priority;
124 Set_Priority (T, T.Common.Base_Priority);
125 end if;
126 end Change_Base_Priority;
128 ------------------------
129 -- Check_Abort_Status --
130 ------------------------
132 function Check_Abort_Status return Integer is
133 Self_ID : constant Task_Id := Self;
134 begin
135 if Self_ID /= null and then Self_ID.Deferral_Level = 0
136 and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level
137 then
138 return 1;
139 else
140 return 0;
141 end if;
142 end Check_Abort_Status;
144 -----------------
145 -- Defer_Abort --
146 -----------------
148 procedure Defer_Abort (Self_ID : Task_Id) is
149 begin
150 if No_Abort then
151 return;
152 end if;
154 pragma Assert (Self_ID.Deferral_Level = 0);
156 -- pragma Assert
157 -- (Self_ID.Pending_ATC_Level >= Self_ID.ATC_Nesting_Level);
159 -- The above check has been useful in detecting mismatched defer/undefer
160 -- pairs. You may uncomment it when testing on systems that support
161 -- preemptive abort.
163 -- If the OS supports preemptive abort (e.g. pthread_kill), it should
164 -- have happened already. A problem is with systems that do not support
165 -- preemptive abort, and so rely on polling. On such systems we may get
166 -- false failures of the assertion, since polling for pending abort does
167 -- no occur until the abort undefer operation.
169 -- Even on systems that only poll for abort, the assertion may be useful
170 -- for catching missed abort completion polling points. The operations
171 -- that undefer abort poll for pending aborts. This covers most of the
172 -- places where the core Ada semantics require abort to be caught,
173 -- without any special attention. However, this generally happens on
174 -- exit from runtime system call, which means a pending abort will not
175 -- be noticed on the way into the runtime system. We considered adding a
176 -- check for pending aborts at this point, but chose not to, because of
177 -- the overhead. Instead, we searched for RTS calls where abort
178 -- completion is required and a task could go farther than Ada allows
179 -- before undeferring abort; we then modified the code to ensure the
180 -- abort would be detected.
182 Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1;
183 end Defer_Abort;
185 --------------------------
186 -- Defer_Abort_Nestable --
187 --------------------------
189 procedure Defer_Abort_Nestable (Self_ID : Task_Id) is
190 begin
191 if No_Abort then
192 return;
193 end if;
195 -- pragma Assert
196 -- ((Self_ID.Pending_ATC_Level >= Self_ID.ATC_Nesting_Level or else
197 -- Self_ID.Deferral_Level > 0));
199 -- See comment in Defer_Abort on the situations in which it may be
200 -- useful to uncomment the above assertion.
202 Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1;
203 end Defer_Abort_Nestable;
205 -----------------
206 -- Abort_Defer --
207 -----------------
209 procedure Abort_Defer is
210 Self_ID : Task_Id;
211 begin
212 if No_Abort then
213 return;
214 end if;
216 Self_ID := STPO.Self;
217 Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1;
218 end Abort_Defer;
220 -----------------------
221 -- Get_Current_Excep --
222 -----------------------
224 function Get_Current_Excep return SSL.EOA is
225 begin
226 return STPO.Self.Common.Compiler_Data.Current_Excep'Access;
227 end Get_Current_Excep;
229 -----------------------
230 -- Do_Pending_Action --
231 -----------------------
233 -- Call only when holding no locks
235 procedure Do_Pending_Action (Self_ID : Task_Id) is
236 use type Ada.Exceptions.Exception_Id;
238 begin
239 pragma Assert (Self_ID = Self and then Self_ID.Deferral_Level = 0);
241 -- Needs loop to recheck for pending action in case a new one occurred
242 -- while we had abort deferred below.
244 loop
245 -- Temporarily defer abort so that we can lock Self_ID
247 Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1;
249 if Single_Lock then
250 Lock_RTS;
251 end if;
253 Write_Lock (Self_ID);
254 Self_ID.Pending_Action := False;
255 Unlock (Self_ID);
257 if Single_Lock then
258 Unlock_RTS;
259 end if;
261 -- Restore the original Deferral value
263 Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1;
265 if not Self_ID.Pending_Action then
266 if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level then
267 if not Self_ID.Aborting then
268 Self_ID.Aborting := True;
269 pragma Debug
270 (Debug.Trace (Self_ID, "raise Abort_Signal", 'B'));
271 raise Standard'Abort_Signal;
273 pragma Assert (not Self_ID.ATC_Hack);
275 elsif Self_ID.ATC_Hack then
276 -- The solution really belongs in the Abort_Signal handler
277 -- for async. entry calls. The present hack is very
278 -- fragile. It relies that the very next point after
279 -- Exit_One_ATC_Level at which the task becomes abortable
280 -- will be the call to Undefer_Abort in the
281 -- Abort_Signal handler.
283 Self_ID.ATC_Hack := False;
285 pragma Debug
286 (Debug.Trace
287 (Self_ID, "raise Abort_Signal (ATC hack)", 'B'));
288 raise Standard'Abort_Signal;
289 end if;
290 end if;
292 return;
293 end if;
294 end loop;
295 end Do_Pending_Action;
297 -----------------------
298 -- Final_Task_Unlock --
299 -----------------------
301 -- This version is only for use in Terminate_Task, when the task
302 -- is relinquishing further rights to its own ATCB.
303 -- There is a very interesting potential race condition there, where
304 -- the old task may run concurrently with a new task that is allocated
305 -- the old tasks (now reused) ATCB. The critical thing here is to
306 -- not make any reference to the ATCB after the lock is released.
307 -- See also comments on Terminate_Task and Unlock.
309 procedure Final_Task_Unlock (Self_ID : Task_Id) is
310 begin
311 pragma Assert (Self_ID.Common.Global_Task_Lock_Nesting = 1);
312 Unlock (Global_Task_Lock'Access, Global_Lock => True);
313 end Final_Task_Unlock;
315 --------------
316 -- Init_RTS --
317 --------------
319 procedure Init_RTS is
320 Self_Id : Task_Id;
321 begin
322 Tasking.Initialize;
324 -- Terminate run time (regular vs restricted) specific initialization
325 -- of the environment task.
327 Self_Id := Environment_Task;
328 Self_Id.Master_of_Task := Environment_Task_Level;
329 Self_Id.Master_Within := Self_Id.Master_of_Task + 1;
331 for L in Self_Id.Entry_Calls'Range loop
332 Self_Id.Entry_Calls (L).Self := Self_Id;
333 Self_Id.Entry_Calls (L).Level := L;
334 end loop;
336 Self_Id.Awake_Count := 1;
337 Self_Id.Alive_Count := 1;
339 Self_Id.Master_Within := Library_Task_Level;
340 -- Normally, a task starts out with internal master nesting level
341 -- one larger than external master nesting level. It is incremented
342 -- to one by Enter_Master, which is called in the task body only if
343 -- the compiler thinks the task may have dependent tasks. There is no
344 -- corresponding call to Enter_Master for the environment task, so we
345 -- would need to increment it to 2 here. Instead, we set it to 3.
346 -- By doing this we reserve the level 2 for server tasks of the runtime
347 -- system. The environment task does not need to wait for these server
349 -- Initialize lock used to implement mutual exclusion between all tasks
351 Initialize_Lock (Global_Task_Lock'Access, STPO.Global_Task_Level);
353 -- Notify that the tasking run time has been elaborated so that
354 -- the tasking version of the soft links can be used.
356 if not No_Abort then
357 SSL.Abort_Defer := Abort_Defer'Access;
358 SSL.Abort_Undefer := Abort_Undefer'Access;
359 end if;
361 SSL.Lock_Task := Task_Lock'Access;
362 SSL.Unlock_Task := Task_Unlock'Access;
363 SSL.Check_Abort_Status := Check_Abort_Status'Access;
364 SSL.Task_Name := Task_Name'Access;
365 SSL.Update_Exception := Update_Exception'Access;
366 SSL.Get_Current_Excep := Get_Current_Excep'Access;
368 -- Initialize the tasking soft links (if not done yet) that are common
369 -- to the full and the restricted run times.
371 SSL.Tasking.Init_Tasking_Soft_Links;
373 -- Abort is deferred in a new ATCB, so we need to undefer abort
374 -- at this stage to make the environment task abortable.
376 Undefer_Abort (Environment_Task);
377 end Init_RTS;
379 ---------------------------
380 -- Locked_Abort_To_Level--
381 ---------------------------
383 -- Abort a task to the specified ATC nesting level.
384 -- Call this only with T locked.
386 -- An earlier version of this code contained a call to Wakeup. That
387 -- should not be necessary here, if Abort_Task is implemented correctly,
388 -- since Abort_Task should include the effect of Wakeup. However, the
389 -- above call was in earlier versions of this file, and at least for
390 -- some targets Abort_Task has not been doing Wakeup. It should not
391 -- hurt to uncomment the above call, until the error is corrected for
392 -- all targets.
394 -- See extended comments in package body System.Tasking.Abort for the
395 -- overall design of the implementation of task abort.
396 -- ??? there is no such package ???
398 -- If the task is sleeping it will be in an abort-deferred region, and
399 -- will not have Abort_Signal raised by Abort_Task. Such an "abort
400 -- deferral" is just to protect the RTS internals, and not necessarily
401 -- required to enforce Ada semantics. Abort_Task should wake the task up
402 -- and let it decide if it wants to complete the aborted construct
403 -- immediately.
405 -- Note that the effect of the low-level Abort_Task is not persistent.
406 -- If the target task is not blocked, this wakeup will be missed.
408 -- We don't bother calling Abort_Task if this task is aborting itself,
409 -- since we are inside the RTS and have abort deferred. Similarly, We
410 -- don't bother to call Abort_Task if T is terminated, since there is
411 -- no need to abort a terminated task, and it could be dangerous to try
412 -- if the task has stopped executing.
414 -- Note that an earlier version of this code had some false reasoning
415 -- about being able to reliably wake up a task that had suspended on
416 -- a blocking system call that does not atomically release the task's
417 -- lock (e.g., UNIX nanosleep, which we once thought could be used to
418 -- implement delays). That still left the possibility of missed
419 -- wakeups.
421 -- We cannot safely call Vulnerable_Complete_Activation here, since that
422 -- requires locking Self_ID.Parent. The anti-deadlock lock ordering rules
423 -- would then require us to release the lock on Self_ID first, which would
424 -- create a timing window for other tasks to lock Self_ID. This is
425 -- significant for tasks that may be aborted before their execution can
426 -- enter the task body, and so they do not get a chance to call
427 -- Complete_Task. The actual work for this case is done in Terminate_Task.
429 procedure Locked_Abort_To_Level
430 (Self_ID : Task_Id;
431 T : Task_Id;
432 L : ATC_Level)
434 begin
435 if not T.Aborting and then T /= Self_ID then
436 case T.Common.State is
437 when Unactivated | Terminated =>
438 pragma Assert (False);
439 null;
441 when Runnable =>
442 -- This is needed to cancel an asynchronous protected entry
443 -- call during a requeue with abort.
445 T.Entry_Calls
446 (T.ATC_Nesting_Level).Cancellation_Attempted := True;
448 when Interrupt_Server_Blocked_On_Event_Flag =>
449 null;
451 when Delay_Sleep |
452 Async_Select_Sleep |
453 Interrupt_Server_Idle_Sleep |
454 Interrupt_Server_Blocked_Interrupt_Sleep |
455 Timer_Server_Sleep |
456 AST_Server_Sleep =>
457 Wakeup (T, T.Common.State);
459 when Acceptor_Sleep =>
460 T.Open_Accepts := null;
461 Wakeup (T, T.Common.State);
463 when Entry_Caller_Sleep =>
464 T.Entry_Calls
465 (T.ATC_Nesting_Level).Cancellation_Attempted := True;
466 Wakeup (T, T.Common.State);
468 when Activator_Sleep |
469 Master_Completion_Sleep |
470 Master_Phase_2_Sleep |
471 Asynchronous_Hold =>
472 null;
473 end case;
474 end if;
476 if T.Pending_ATC_Level > L then
477 T.Pending_ATC_Level := L;
478 T.Pending_Action := True;
480 if L = 0 then
481 T.Callable := False;
482 end if;
484 -- This prevents aborted task from accepting calls
486 if T.Aborting then
488 -- The test above is just a heuristic, to reduce wasteful
489 -- calls to Abort_Task. We are holding T locked, and this
490 -- value will not be set to False except with T also locked,
491 -- inside Exit_One_ATC_Level, so we should not miss wakeups.
493 if T.Common.State = Acceptor_Sleep then
494 T.Open_Accepts := null;
495 end if;
497 elsif T /= Self_ID and then
498 (T.Common.State = Runnable
499 or else T.Common.State = Interrupt_Server_Blocked_On_Event_Flag)
500 -- The task is blocked on a system call waiting for the
501 -- completion event. In this case Abort_Task may need to take
502 -- special action in order to succeed. Example system: VMS.
504 then
505 Abort_Task (T);
506 end if;
507 end if;
508 end Locked_Abort_To_Level;
510 --------------------------------
511 -- Remove_From_All_Tasks_List --
512 --------------------------------
514 procedure Remove_From_All_Tasks_List (T : Task_Id) is
515 C : Task_Id;
516 Previous : Task_Id;
518 begin
519 pragma Debug
520 (Debug.Trace (Self, "Remove_From_All_Tasks_List", 'C'));
522 Previous := Null_Task;
523 C := All_Tasks_List;
525 while C /= Null_Task loop
526 if C = T then
527 if Previous = Null_Task then
528 All_Tasks_List :=
529 All_Tasks_List.Common.All_Tasks_Link;
530 else
531 Previous.Common.All_Tasks_Link := C.Common.All_Tasks_Link;
532 end if;
534 return;
535 end if;
537 Previous := C;
538 C := C.Common.All_Tasks_Link;
539 end loop;
541 pragma Assert (False);
542 end Remove_From_All_Tasks_List;
544 ---------------
545 -- Task_Lock --
546 ---------------
548 procedure Task_Lock (Self_ID : Task_Id) is
549 begin
550 Self_ID.Common.Global_Task_Lock_Nesting :=
551 Self_ID.Common.Global_Task_Lock_Nesting + 1;
553 if Self_ID.Common.Global_Task_Lock_Nesting = 1 then
554 Defer_Abort_Nestable (Self_ID);
555 Write_Lock (Global_Task_Lock'Access, Global_Lock => True);
556 end if;
557 end Task_Lock;
559 procedure Task_Lock is
560 begin
561 Task_Lock (STPO.Self);
562 end Task_Lock;
564 ---------------
565 -- Task_Name --
566 ---------------
568 function Task_Name return String is
569 Self_Id : constant Task_Id := STPO.Self;
571 begin
572 return Self_Id.Common.Task_Image (1 .. Self_Id.Common.Task_Image_Len);
573 end Task_Name;
575 -----------------
576 -- Task_Unlock --
577 -----------------
579 procedure Task_Unlock (Self_ID : Task_Id) is
580 begin
581 pragma Assert (Self_ID.Common.Global_Task_Lock_Nesting > 0);
582 Self_ID.Common.Global_Task_Lock_Nesting :=
583 Self_ID.Common.Global_Task_Lock_Nesting - 1;
585 if Self_ID.Common.Global_Task_Lock_Nesting = 0 then
586 Unlock (Global_Task_Lock'Access, Global_Lock => True);
587 Undefer_Abort_Nestable (Self_ID);
588 end if;
589 end Task_Unlock;
591 procedure Task_Unlock is
592 begin
593 Task_Unlock (STPO.Self);
594 end Task_Unlock;
596 -------------------
597 -- Undefer_Abort --
598 -------------------
600 -- Precondition : Self does not hold any locks!
602 -- Undefer_Abort is called on any abort completion point (aka.
603 -- synchronization point). It performs the following actions if they
604 -- are pending: (1) change the base priority, (2) abort the task.
606 -- The priority change has to occur before abort. Otherwise, it would
607 -- take effect no earlier than the next abort completion point.
609 procedure Undefer_Abort (Self_ID : Task_Id) is
610 begin
611 if No_Abort then
612 return;
613 end if;
615 pragma Assert (Self_ID.Deferral_Level = 1);
617 Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1;
619 if Self_ID.Deferral_Level = 0 then
620 pragma Assert (Check_No_Locks (Self_ID));
622 if Self_ID.Pending_Action then
623 Do_Pending_Action (Self_ID);
624 end if;
625 end if;
626 end Undefer_Abort;
628 ----------------------------
629 -- Undefer_Abort_Nestable --
630 ----------------------------
632 -- An earlier version would re-defer abort if an abort is in progress.
633 -- Then, we modified the effect of the raise statement so that it defers
634 -- abort until control reaches a handler. That was done to prevent
635 -- "skipping over" a handler if another asynchronous abort occurs during
636 -- the propagation of the abort to the handler.
638 -- There has been talk of reversing that decision, based on a newer
639 -- implementation of exception propagation. Care must be taken to evaluate
640 -- how such a change would interact with the above code and all the places
641 -- where abort-deferral is used to bridge over critical transitions, such
642 -- as entry to the scope of a region with a finalizer and entry into the
643 -- body of an accept-procedure.
645 procedure Undefer_Abort_Nestable (Self_ID : Task_Id) is
646 begin
647 if No_Abort then
648 return;
649 end if;
651 pragma Assert (Self_ID.Deferral_Level > 0);
653 Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1;
655 if Self_ID.Deferral_Level = 0 then
657 pragma Assert (Check_No_Locks (Self_ID));
659 if Self_ID.Pending_Action then
660 Do_Pending_Action (Self_ID);
661 end if;
662 end if;
663 end Undefer_Abort_Nestable;
665 -------------------
666 -- Abort_Undefer --
667 -------------------
669 procedure Abort_Undefer is
670 Self_ID : Task_Id;
671 begin
672 if No_Abort then
673 return;
674 end if;
676 Self_ID := STPO.Self;
678 if Self_ID.Deferral_Level = 0 then
680 -- In case there are different views on whether Abort is supported
681 -- between the expander and the run time, we may end up with
682 -- Self_ID.Deferral_Level being equal to zero, when called from
683 -- the procedure created by the expander that corresponds to a
684 -- task body.
686 -- In this case, there's nothing to be done
688 -- See related code in System.Tasking.Stages.Create_Task resetting
689 -- Deferral_Level when System.Restrictions.Abort_Allowed is False.
691 return;
692 end if;
694 pragma Assert (Self_ID.Deferral_Level > 0);
695 Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1;
697 if Self_ID.Deferral_Level = 0 then
698 pragma Assert (Check_No_Locks (Self_ID));
700 if Self_ID.Pending_Action then
701 Do_Pending_Action (Self_ID);
702 end if;
703 end if;
704 end Abort_Undefer;
706 ----------------------
707 -- Update_Exception --
708 ----------------------
710 -- Call only when holding no locks
712 procedure Update_Exception
713 (X : AE.Exception_Occurrence := SSL.Current_Target_Exception)
715 Self_Id : constant Task_Id := Self;
716 use Ada.Exceptions;
718 begin
719 Save_Occurrence (Self_Id.Common.Compiler_Data.Current_Excep, X);
721 if Self_Id.Deferral_Level = 0 then
722 if Self_Id.Pending_Action then
723 Self_Id.Pending_Action := False;
724 Self_Id.Deferral_Level := Self_Id.Deferral_Level + 1;
726 if Single_Lock then
727 Lock_RTS;
728 end if;
730 Write_Lock (Self_Id);
731 Self_Id.Pending_Action := False;
732 Unlock (Self_Id);
734 if Single_Lock then
735 Unlock_RTS;
736 end if;
738 Self_Id.Deferral_Level := Self_Id.Deferral_Level - 1;
740 if Self_Id.Pending_ATC_Level < Self_Id.ATC_Nesting_Level then
741 if not Self_Id.Aborting then
742 Self_Id.Aborting := True;
743 raise Standard'Abort_Signal;
744 end if;
745 end if;
746 end if;
747 end if;
748 end Update_Exception;
750 --------------------------
751 -- Wakeup_Entry_Caller --
752 --------------------------
754 -- This is called at the end of service of an entry call, to abort the
755 -- caller if he is in an abortable part, and to wake up the caller if it
756 -- is on Entry_Caller_Sleep. It assumes that the call is already off-queue.
758 -- (This enforces the rule that a task must be off-queue if its state is
759 -- Done or Cancelled.) Call it holding the lock of Entry_Call.Self.
761 -- Timed_Call or Simple_Call:
762 -- The caller is waiting on Entry_Caller_Sleep, in
763 -- Wait_For_Completion, or Wait_For_Completion_With_Timeout.
765 -- Conditional_Call:
766 -- The caller might be in Wait_For_Completion,
767 -- waiting for a rendezvous (possibly requeued without abort)
768 -- to complete.
770 -- Asynchronous_Call:
771 -- The caller may be executing in the abortable part o
772 -- an async. select, or on a time delay,
773 -- if Entry_Call.State >= Was_Abortable.
775 procedure Wakeup_Entry_Caller
776 (Self_ID : Task_Id;
777 Entry_Call : Entry_Call_Link;
778 New_State : Entry_Call_State)
780 Caller : constant Task_Id := Entry_Call.Self;
781 begin
782 pragma Debug (Debug.Trace
783 (Self_ID, "Wakeup_Entry_Caller", 'E', Caller));
784 pragma Assert (New_State = Done or else New_State = Cancelled);
786 pragma Assert (Caller.Common.State /= Unactivated);
788 Entry_Call.State := New_State;
790 if Entry_Call.Mode = Asynchronous_Call then
792 -- Abort the caller in his abortable part,
793 -- but do so only if call has been queued abortably
795 if Entry_Call.State >= Was_Abortable or else New_State = Done then
796 Locked_Abort_To_Level (Self_ID, Caller, Entry_Call.Level - 1);
797 end if;
799 elsif Caller.Common.State = Entry_Caller_Sleep then
800 Wakeup (Caller, Entry_Caller_Sleep);
801 end if;
802 end Wakeup_Entry_Caller;
804 -----------------------
805 -- Soft-Link Dummies --
806 -----------------------
808 -- These are dummies for subprograms that are only needed by certain
809 -- optional run-time system packages. If they are needed, the soft
810 -- links will be redirected to the real subprogram by elaboration of
811 -- the subprogram body where the real subprogram is declared.
813 procedure Finalize_Attributes (T : Task_Id) is
814 pragma Unreferenced (T);
815 begin
816 null;
817 end Finalize_Attributes;
819 procedure Initialize_Attributes (T : Task_Id) is
820 pragma Unreferenced (T);
821 begin
822 null;
823 end Initialize_Attributes;
825 begin
826 Init_RTS;
827 end System.Tasking.Initialization;