libgo: correct golang_org Makefile variables not used on all systems
[official-gcc.git] / gcc / ada / s-tasini.adb
blob48444431c52f4bdf154534a67070a1575070b33b
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-2016, 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 3, or (at your option) any later ver- --
14 -- sion. GNAT 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. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNARL was developed by the GNARL team at Florida State University. --
28 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
29 -- --
30 ------------------------------------------------------------------------------
32 pragma Style_Checks (All_Checks);
33 -- Turn off subprogram alpha ordering check, since we group soft link bodies
34 -- and dummy soft link bodies together separately in this unit.
36 pragma Polling (Off);
37 -- Turn polling off for this package. We don't need polling during any of the
38 -- routines in this package, and more to the point, if we try to poll it can
39 -- cause infinite loops.
41 with Ada.Exceptions;
43 with System.Task_Primitives;
44 with System.Task_Primitives.Operations;
45 with System.Soft_Links;
46 with System.Soft_Links.Tasking;
47 with System.Tasking.Debug;
48 with System.Tasking.Task_Attributes;
49 with System.Parameters;
51 with System.Secondary_Stack;
52 pragma Elaborate_All (System.Secondary_Stack);
53 pragma Unreferenced (System.Secondary_Stack);
54 -- Make sure the body of Secondary_Stack is elaborated before calling
55 -- Init_Tasking_Soft_Links. See comments for this routine for explanation.
57 package body System.Tasking.Initialization is
59 package STPO renames System.Task_Primitives.Operations;
60 package SSL renames System.Soft_Links;
62 use Parameters;
63 use Task_Primitives.Operations;
65 Global_Task_Lock : aliased System.Task_Primitives.RTS_Lock;
66 -- This is a global lock; it is used to execute in mutual exclusion from
67 -- all other tasks. It is only used by Task_Lock, Task_Unlock, and
68 -- Final_Task_Unlock.
70 ----------------------------------------------------------------------
71 -- Tasking versions of some services needed by non-tasking programs --
72 ----------------------------------------------------------------------
74 procedure Abort_Defer;
75 -- NON-INLINE versions without Self_ID for soft links
77 procedure Abort_Undefer;
78 -- NON-INLINE versions without Self_ID for soft links
80 procedure Task_Lock;
81 -- Locks out other tasks. Preceding a section of code by Task_Lock and
82 -- following it by Task_Unlock creates a critical region. This is used
83 -- for ensuring that a region of non-tasking code (such as code used to
84 -- allocate memory) is tasking safe. Note that it is valid for calls to
85 -- Task_Lock/Task_Unlock to be nested, and this must work properly, i.e.
86 -- only the corresponding outer level Task_Unlock will actually unlock.
88 procedure Task_Unlock;
89 -- Releases lock previously set by call to Task_Lock. In the nested case,
90 -- all nested locks must be released before other tasks competing for the
91 -- tasking lock are released.
93 function Get_Current_Excep return SSL.EOA;
94 -- Task-safe version of SSL.Get_Current_Excep
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 part
109 -- of the initialization is done in the body of System.Tasking. It consists
110 -- of initializing global locks, and installing tasking versions of certain
111 -- operations used by the compiler. Init_RTS is called during elaboration.
113 --------------------------
114 -- Change_Base_Priority --
115 --------------------------
117 -- Call only with abort deferred and holding Self_ID locked
119 procedure Change_Base_Priority (T : Task_Id) is
120 begin
121 if T.Common.Base_Priority /= T.New_Base_Priority then
122 T.Common.Base_Priority := T.New_Base_Priority;
123 Set_Priority (T, T.Common.Base_Priority);
124 end if;
125 end Change_Base_Priority;
127 ------------------------
128 -- Check_Abort_Status --
129 ------------------------
131 function Check_Abort_Status return Integer is
132 Self_ID : constant Task_Id := Self;
133 begin
134 if Self_ID /= null
135 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 -- The following assertion is by default disabled. See the comment in
196 -- Defer_Abort on the situations in which it may be useful to uncomment
197 -- this assertion and enable the test.
199 -- pragma Assert
200 -- (Self_ID.Pending_ATC_Level >= Self_ID.ATC_Nesting_Level or else
201 -- Self_ID.Deferral_Level > 0);
203 Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1;
204 end Defer_Abort_Nestable;
206 -----------------
207 -- Abort_Defer --
208 -----------------
210 procedure Abort_Defer is
211 Self_ID : Task_Id;
212 begin
213 if No_Abort then
214 return;
215 end if;
217 Self_ID := STPO.Self;
218 Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1;
219 end Abort_Defer;
221 -----------------------
222 -- Get_Current_Excep --
223 -----------------------
225 function Get_Current_Excep return SSL.EOA is
226 begin
227 return STPO.Self.Common.Compiler_Data.Current_Excep'Access;
228 end Get_Current_Excep;
230 -----------------------
231 -- Do_Pending_Action --
232 -----------------------
234 -- Call only when holding no locks
236 procedure Do_Pending_Action (Self_ID : Task_Id) is
237 use type Ada.Exceptions.Exception_Id;
239 begin
240 pragma Assert (Self_ID = Self and then Self_ID.Deferral_Level = 0);
242 -- Needs loop to recheck for pending action in case a new one occurred
243 -- while we had abort deferred below.
245 loop
246 -- Temporarily defer abort so that we can lock Self_ID
248 Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1;
250 if Single_Lock then
251 Lock_RTS;
252 end if;
254 Write_Lock (Self_ID);
255 Self_ID.Pending_Action := False;
256 Unlock (Self_ID);
258 if Single_Lock then
259 Unlock_RTS;
260 end if;
262 -- Restore the original Deferral value
264 Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1;
266 if not Self_ID.Pending_Action then
267 if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level then
268 if not Self_ID.Aborting then
269 Self_ID.Aborting := True;
270 pragma Debug
271 (Debug.Trace (Self_ID, "raise Abort_Signal", 'B'));
272 raise Standard'Abort_Signal;
274 pragma Assert (not Self_ID.ATC_Hack);
276 elsif Self_ID.ATC_Hack then
278 -- The solution really belongs in the Abort_Signal handler
279 -- for async. entry calls. The present hack is very
280 -- fragile. It relies that the very next point after
281 -- Exit_One_ATC_Level at which the task becomes abortable
282 -- will be the call to Undefer_Abort in the
283 -- Abort_Signal handler.
285 Self_ID.ATC_Hack := False;
287 pragma Debug
288 (Debug.Trace
289 (Self_ID, "raise Abort_Signal (ATC hack)", 'B'));
290 raise Standard'Abort_Signal;
291 end if;
292 end if;
294 return;
295 end if;
296 end loop;
297 end Do_Pending_Action;
299 -----------------------
300 -- Final_Task_Unlock --
301 -----------------------
303 -- This version is only for use in Terminate_Task, when the task is
304 -- relinquishing further rights to its own ATCB.
306 -- There is a very interesting potential race condition there, where the
307 -- old task may run concurrently with a new task that is allocated the old
308 -- tasks (now reused) ATCB. The critical thing here is to not make any
309 -- reference to the ATCB after the lock is released. See also comments on
310 -- Terminate_Task and Unlock.
312 procedure Final_Task_Unlock (Self_ID : Task_Id) is
313 begin
314 pragma Assert (Self_ID.Common.Global_Task_Lock_Nesting = 1);
315 Unlock (Global_Task_Lock'Access, Global_Lock => True);
316 end Final_Task_Unlock;
318 --------------
319 -- Init_RTS --
320 --------------
322 procedure Init_RTS is
323 Self_Id : Task_Id;
324 begin
325 Tasking.Initialize;
327 -- Terminate run time (regular vs restricted) specific initialization
328 -- of the environment task.
330 Self_Id := Environment_Task;
331 Self_Id.Master_of_Task := Environment_Task_Level;
332 Self_Id.Master_Within := Self_Id.Master_of_Task + 1;
334 for L in Self_Id.Entry_Calls'Range loop
335 Self_Id.Entry_Calls (L).Self := Self_Id;
336 Self_Id.Entry_Calls (L).Level := L;
337 end loop;
339 Self_Id.Awake_Count := 1;
340 Self_Id.Alive_Count := 1;
342 -- Normally, a task starts out with internal master nesting level one
343 -- larger than external master nesting level. It is incremented to one
344 -- by Enter_Master, which is called in the task body only if the
345 -- compiler thinks the task may have dependent tasks. There is no
346 -- corresponding call to Enter_Master for the environment task, so we
347 -- would need to increment it to 2 here. Instead, we set it to 3. By
348 -- doing this we reserve the level 2 for server tasks of the runtime
349 -- system. The environment task does not need to wait for these server
351 Self_Id.Master_Within := Library_Task_Level;
353 -- Initialize lock used to implement mutual exclusion between all tasks
355 Initialize_Lock (Global_Task_Lock'Access, STPO.Global_Task_Level);
357 -- Notify that the tasking run time has been elaborated so that
358 -- the tasking version of the soft links can be used.
360 if not No_Abort then
361 SSL.Abort_Defer := Abort_Defer'Access;
362 SSL.Abort_Undefer := Abort_Undefer'Access;
363 end if;
365 SSL.Lock_Task := Task_Lock'Access;
366 SSL.Unlock_Task := Task_Unlock'Access;
367 SSL.Check_Abort_Status := Check_Abort_Status'Access;
368 SSL.Task_Name := Task_Name'Access;
369 SSL.Get_Current_Excep := Get_Current_Excep'Access;
371 -- Initialize the tasking soft links (if not done yet) that are common
372 -- to the full and the restricted run times.
374 SSL.Tasking.Init_Tasking_Soft_Links;
376 -- Abort is deferred in a new ATCB, so we need to undefer abort at this
377 -- stage to make the environment task abortable.
379 Undefer_Abort (Environment_Task);
380 end Init_RTS;
382 ---------------------------
383 -- Locked_Abort_To_Level--
384 ---------------------------
386 -- Abort a task to the specified ATC nesting level.
387 -- Call this only with T locked.
389 -- An earlier version of this code contained a call to Wakeup. That should
390 -- not be necessary here, if Abort_Task is implemented correctly, since
391 -- Abort_Task should include the effect of Wakeup. However, the above call
392 -- was in earlier versions of this file, and at least for some targets
393 -- Abort_Task has not been doing Wakeup. It should not hurt to uncomment
394 -- the above call, until the error is corrected for all targets.
396 -- See extended comments in package body System.Tasking.Abort for the
397 -- overall design of the implementation of task abort.
398 -- ??? there is no such package ???
400 -- If the task is sleeping it will be in an abort-deferred region, and will
401 -- not have Abort_Signal raised by Abort_Task. Such an "abort deferral" is
402 -- just to protect the RTS internals, and not necessarily required to
403 -- enforce Ada semantics. Abort_Task should wake the task up and let it
404 -- decide if it wants to complete the aborted construct immediately.
406 -- Note that the effect of the low-level Abort_Task is not persistent.
407 -- If the target task is not blocked, this wakeup will be missed.
409 -- We don't bother calling Abort_Task if this task is aborting itself,
410 -- since we are inside the RTS and have abort deferred. Similarly, We don't
411 -- bother to call Abort_Task if T is terminated, since there is no need to
412 -- abort a terminated task, and it could be dangerous to try if the task
413 -- has stopped executing.
415 -- Note that an earlier version of this code had some false reasoning about
416 -- being able to reliably wake up a task that had suspended on a blocking
417 -- system call that does not atomically release the task's lock (e.g., UNIX
418 -- nanosleep, which we once thought could be used to implement delays).
419 -- That still left the possibility of missed 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 Terminated
438 | Unactivated
440 pragma Assert (False);
441 null;
443 when Activating
444 | Runnable
446 -- This is needed to cancel an asynchronous protected entry
447 -- call during a requeue with abort.
449 T.Entry_Calls
450 (T.ATC_Nesting_Level).Cancellation_Attempted := True;
452 when Interrupt_Server_Blocked_On_Event_Flag =>
453 null;
455 when AST_Server_Sleep
456 | Async_Select_Sleep
457 | Delay_Sleep
458 | Interrupt_Server_Blocked_Interrupt_Sleep
459 | Interrupt_Server_Idle_Sleep
460 | Timer_Server_Sleep
462 Wakeup (T, T.Common.State);
464 when Acceptor_Delay_Sleep
465 | Acceptor_Sleep
467 T.Open_Accepts := null;
468 Wakeup (T, T.Common.State);
470 when Entry_Caller_Sleep =>
471 T.Entry_Calls
472 (T.ATC_Nesting_Level).Cancellation_Attempted := True;
473 Wakeup (T, T.Common.State);
475 when Activator_Sleep
476 | Asynchronous_Hold
477 | Master_Completion_Sleep
478 | Master_Phase_2_Sleep
480 null;
481 end case;
482 end if;
484 if T.Pending_ATC_Level > L then
485 T.Pending_ATC_Level := L;
486 T.Pending_Action := True;
488 if L = 0 then
489 T.Callable := False;
490 end if;
492 -- This prevents aborted task from accepting calls
494 if T.Aborting then
496 -- The test above is just a heuristic, to reduce wasteful
497 -- calls to Abort_Task. We are holding T locked, and this
498 -- value will not be set to False except with T also locked,
499 -- inside Exit_One_ATC_Level, so we should not miss wakeups.
501 if T.Common.State = Acceptor_Sleep
502 or else
503 T.Common.State = Acceptor_Delay_Sleep
504 then
505 T.Open_Accepts := null;
506 end if;
508 elsif T /= Self_ID and then
509 (T.Common.State = Runnable
510 or else T.Common.State = Interrupt_Server_Blocked_On_Event_Flag)
512 -- The task is blocked on a system call waiting for the
513 -- completion event. In this case Abort_Task may need to take
514 -- special action in order to succeed.
516 then
517 Abort_Task (T);
518 end if;
519 end if;
520 end Locked_Abort_To_Level;
522 --------------------------------
523 -- Remove_From_All_Tasks_List --
524 --------------------------------
526 procedure Remove_From_All_Tasks_List (T : Task_Id) is
527 C : Task_Id;
528 Previous : Task_Id;
530 begin
531 pragma Debug
532 (Debug.Trace (Self, "Remove_From_All_Tasks_List", 'C'));
534 Previous := Null_Task;
535 C := All_Tasks_List;
536 while C /= Null_Task loop
537 if C = T then
538 if Previous = Null_Task then
539 All_Tasks_List := All_Tasks_List.Common.All_Tasks_Link;
540 else
541 Previous.Common.All_Tasks_Link := C.Common.All_Tasks_Link;
542 end if;
544 return;
545 end if;
547 Previous := C;
548 C := C.Common.All_Tasks_Link;
549 end loop;
551 pragma Assert (False);
552 end Remove_From_All_Tasks_List;
554 ---------------
555 -- Task_Lock --
556 ---------------
558 procedure Task_Lock (Self_ID : Task_Id) is
559 begin
560 Self_ID.Common.Global_Task_Lock_Nesting :=
561 Self_ID.Common.Global_Task_Lock_Nesting + 1;
563 if Self_ID.Common.Global_Task_Lock_Nesting = 1 then
564 Defer_Abort_Nestable (Self_ID);
565 Write_Lock (Global_Task_Lock'Access, Global_Lock => True);
566 end if;
567 end Task_Lock;
569 procedure Task_Lock is
570 begin
571 Task_Lock (STPO.Self);
572 end Task_Lock;
574 ---------------
575 -- Task_Name --
576 ---------------
578 function Task_Name return String is
579 Self_Id : constant Task_Id := STPO.Self;
580 begin
581 return Self_Id.Common.Task_Image (1 .. Self_Id.Common.Task_Image_Len);
582 end Task_Name;
584 -----------------
585 -- Task_Unlock --
586 -----------------
588 procedure Task_Unlock (Self_ID : Task_Id) is
589 begin
590 pragma Assert (Self_ID.Common.Global_Task_Lock_Nesting > 0);
591 Self_ID.Common.Global_Task_Lock_Nesting :=
592 Self_ID.Common.Global_Task_Lock_Nesting - 1;
594 if Self_ID.Common.Global_Task_Lock_Nesting = 0 then
595 Unlock (Global_Task_Lock'Access, Global_Lock => True);
596 Undefer_Abort_Nestable (Self_ID);
597 end if;
598 end Task_Unlock;
600 procedure Task_Unlock is
601 begin
602 Task_Unlock (STPO.Self);
603 end Task_Unlock;
605 -------------------
606 -- Undefer_Abort --
607 -------------------
609 -- Precondition : Self does not hold any locks
611 -- Undefer_Abort is called on any abort completion point (aka.
612 -- synchronization point). It performs the following actions if they
613 -- are pending: (1) change the base priority, (2) abort the task.
615 -- The priority change has to occur before abort. Otherwise, it would
616 -- take effect no earlier than the next abort completion point.
618 procedure Undefer_Abort (Self_ID : Task_Id) is
619 begin
620 if No_Abort then
621 return;
622 end if;
624 pragma Assert (Self_ID.Deferral_Level = 1);
626 Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1;
628 if Self_ID.Deferral_Level = 0 then
629 pragma Assert (Check_No_Locks (Self_ID));
631 if Self_ID.Pending_Action then
632 Do_Pending_Action (Self_ID);
633 end if;
634 end if;
635 end Undefer_Abort;
637 ----------------------------
638 -- Undefer_Abort_Nestable --
639 ----------------------------
641 -- An earlier version would re-defer abort if an abort is in progress.
642 -- Then, we modified the effect of the raise statement so that it defers
643 -- abort until control reaches a handler. That was done to prevent
644 -- "skipping over" a handler if another asynchronous abort occurs during
645 -- the propagation of the abort to the handler.
647 -- There has been talk of reversing that decision, based on a newer
648 -- implementation of exception propagation. Care must be taken to evaluate
649 -- how such a change would interact with the above code and all the places
650 -- where abort-deferral is used to bridge over critical transitions, such
651 -- as entry to the scope of a region with a finalizer and entry into the
652 -- body of an accept-procedure.
654 procedure Undefer_Abort_Nestable (Self_ID : Task_Id) is
655 begin
656 if No_Abort then
657 return;
658 end if;
660 pragma Assert (Self_ID.Deferral_Level > 0);
662 Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1;
664 if Self_ID.Deferral_Level = 0 then
666 pragma Assert (Check_No_Locks (Self_ID));
668 if Self_ID.Pending_Action then
669 Do_Pending_Action (Self_ID);
670 end if;
671 end if;
672 end Undefer_Abort_Nestable;
674 -------------------
675 -- Abort_Undefer --
676 -------------------
678 procedure Abort_Undefer is
679 Self_ID : Task_Id;
680 begin
681 if No_Abort then
682 return;
683 end if;
685 Self_ID := STPO.Self;
687 if Self_ID.Deferral_Level = 0 then
689 -- In case there are different views on whether Abort is supported
690 -- between the expander and the run time, we may end up with
691 -- Self_ID.Deferral_Level being equal to zero, when called from
692 -- the procedure created by the expander that corresponds to a
693 -- task body. In this case, there's nothing to be done.
695 -- See related code in System.Tasking.Stages.Create_Task resetting
696 -- Deferral_Level when System.Restrictions.Abort_Allowed is False.
698 return;
699 end if;
701 pragma Assert (Self_ID.Deferral_Level > 0);
702 Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1;
704 if Self_ID.Deferral_Level = 0 then
705 pragma Assert (Check_No_Locks (Self_ID));
707 if Self_ID.Pending_Action then
708 Do_Pending_Action (Self_ID);
709 end if;
710 end if;
711 end Abort_Undefer;
713 --------------------------
714 -- Wakeup_Entry_Caller --
715 --------------------------
717 -- This is called at the end of service of an entry call, to abort the
718 -- caller if he is in an abortable part, and to wake up the caller if it
719 -- is on Entry_Caller_Sleep. It assumes that the call is already off-queue.
721 -- (This enforces the rule that a task must be off-queue if its state is
722 -- Done or Cancelled.) Call it holding the lock of Entry_Call.Self.
724 -- Timed_Call or Simple_Call:
725 -- The caller is waiting on Entry_Caller_Sleep, in
726 -- Wait_For_Completion, or Wait_For_Completion_With_Timeout.
728 -- Conditional_Call:
729 -- The caller might be in Wait_For_Completion,
730 -- waiting for a rendezvous (possibly requeued without abort)
731 -- to complete.
733 -- Asynchronous_Call:
734 -- The caller may be executing in the abortable part o
735 -- an async. select, or on a time delay,
736 -- if Entry_Call.State >= Was_Abortable.
738 procedure Wakeup_Entry_Caller
739 (Self_ID : Task_Id;
740 Entry_Call : Entry_Call_Link;
741 New_State : Entry_Call_State)
743 Caller : constant Task_Id := Entry_Call.Self;
745 begin
746 pragma Debug (Debug.Trace
747 (Self_ID, "Wakeup_Entry_Caller", 'E', Caller));
748 pragma Assert (New_State = Done or else New_State = Cancelled);
750 pragma Assert (Caller.Common.State /= Unactivated);
752 Entry_Call.State := New_State;
754 if Entry_Call.Mode = Asynchronous_Call then
756 -- Abort the caller in his abortable part, but do so only if call has
757 -- been queued abortably.
759 if Entry_Call.State >= Was_Abortable or else New_State = Done then
760 Locked_Abort_To_Level (Self_ID, Caller, Entry_Call.Level - 1);
761 end if;
763 elsif Caller.Common.State = Entry_Caller_Sleep then
764 Wakeup (Caller, Entry_Caller_Sleep);
765 end if;
766 end Wakeup_Entry_Caller;
768 -------------------------
769 -- Finalize_Attributes --
770 -------------------------
772 procedure Finalize_Attributes (T : Task_Id) is
773 Attr : Atomic_Address;
775 begin
776 for J in T.Attributes'Range loop
777 Attr := T.Attributes (J);
779 if Attr /= 0 and then Task_Attributes.Require_Finalization (J) then
780 Task_Attributes.To_Attribute (Attr).Free (Attr);
781 T.Attributes (J) := 0;
782 end if;
783 end loop;
784 end Finalize_Attributes;
786 begin
787 Init_RTS;
788 end System.Tasking.Initialization;