* libgfortran.h (support_fpu_underflow_control,
[official-gcc.git] / gcc / ada / s-tarest.adb
blob1436f2a01aaef9bfb1ae1f64ab275425954a1f44
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . T A S K I N G . R E S T R I C T E D . S T A G E S --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1999-2014, 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 order check, since we group soft link
34 -- bodies and also separate off subprograms for restricted GNARLI.
36 -- This is a simplified version of the System.Tasking.Stages package,
37 -- intended to be used in a restricted run time.
39 -- This package represents the high level tasking interface used by the
40 -- compiler to expand Ada 95 tasking constructs into simpler run time calls.
42 pragma Polling (Off);
43 -- Turn off polling, we do not want ATC polling to take place during
44 -- tasking operations. It causes infinite loops and other problems.
46 with Ada.Exceptions;
48 with System.Task_Primitives.Operations;
49 with System.Soft_Links.Tasking;
50 with System.Storage_Elements;
52 with System.Secondary_Stack;
53 pragma Elaborate_All (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 with System.Soft_Links;
58 -- Used for the non-tasking routines (*_NT) that refer to global data. They
59 -- are needed here before the tasking run time has been elaborated. used for
60 -- Create_TSD This package also provides initialization routines for task
61 -- specific data. The GNARL must call these to be sure that all non-tasking
62 -- Ada constructs will work.
64 package body System.Tasking.Restricted.Stages is
66 package STPO renames System.Task_Primitives.Operations;
67 package SSL renames System.Soft_Links;
68 package SSE renames System.Storage_Elements;
69 package SST renames System.Secondary_Stack;
71 use Ada.Exceptions;
73 use Parameters;
74 use Task_Primitives.Operations;
75 use Task_Info;
77 Tasks_Activation_Chain : Task_Id;
78 -- Chain of all the tasks to activate
80 Global_Task_Lock : aliased System.Task_Primitives.RTS_Lock;
81 -- This is a global lock; it is used to execute in mutual exclusion
82 -- from all other tasks. It is only used by Task_Lock and Task_Unlock.
84 -----------------------------------------------------------------
85 -- Tasking versions of services needed by non-tasking programs --
86 -----------------------------------------------------------------
88 function Get_Current_Excep return SSL.EOA;
89 -- Task-safe version of SSL.Get_Current_Excep
91 procedure Task_Lock;
92 -- Locks out other tasks. Preceding a section of code by Task_Lock and
93 -- following it by Task_Unlock creates a critical region. This is used
94 -- for ensuring that a region of non-tasking code (such as code used to
95 -- allocate memory) is tasking safe. Note that it is valid for calls to
96 -- Task_Lock/Task_Unlock to be nested, and this must work properly, i.e.
97 -- only the corresponding outer level Task_Unlock will actually unlock.
99 procedure Task_Unlock;
100 -- Releases lock previously set by call to Task_Lock. In the nested case,
101 -- all nested locks must be released before other tasks competing for the
102 -- tasking lock are released.
104 -----------------------
105 -- Local Subprograms --
106 -----------------------
108 procedure Task_Wrapper (Self_ID : Task_Id);
109 -- This is the procedure that is called by the GNULL from the
110 -- new context when a task is created. It waits for activation
111 -- and then calls the task body procedure. When the task body
112 -- procedure completes, it terminates the task.
114 procedure Terminate_Task (Self_ID : Task_Id);
115 -- Terminate the calling task.
116 -- This should only be called by the Task_Wrapper procedure.
118 procedure Create_Restricted_Task
119 (Priority : Integer;
120 Stack_Address : System.Address;
121 Size : System.Parameters.Size_Type;
122 Task_Info : System.Task_Info.Task_Info_Type;
123 CPU : Integer;
124 State : Task_Procedure_Access;
125 Discriminants : System.Address;
126 Elaborated : Access_Boolean;
127 Task_Image : String;
128 Created_Task : Task_Id);
129 -- Code shared between Create_Restricted_Task_Concurrent and
130 -- Create_Restricted_Task_Sequential. See comment of the former in the
131 -- specification of this package.
133 procedure Activate_Tasks (Chain : Task_Id);
134 -- Activate the list of tasks started by Chain
136 procedure Init_RTS;
137 -- This procedure performs the initialization of the GNARL.
138 -- It consists of initializing the environment task, global locks, and
139 -- installing tasking versions of certain operations used by the compiler.
140 -- Init_RTS is called during elaboration.
142 -----------------------
143 -- Get_Current_Excep --
144 -----------------------
146 function Get_Current_Excep return SSL.EOA is
147 begin
148 return STPO.Self.Common.Compiler_Data.Current_Excep'Access;
149 end Get_Current_Excep;
151 ---------------
152 -- Task_Lock --
153 ---------------
155 procedure Task_Lock is
156 Self_ID : constant Task_Id := STPO.Self;
158 begin
159 Self_ID.Common.Global_Task_Lock_Nesting :=
160 Self_ID.Common.Global_Task_Lock_Nesting + 1;
162 if Self_ID.Common.Global_Task_Lock_Nesting = 1 then
163 STPO.Write_Lock (Global_Task_Lock'Access, Global_Lock => True);
164 end if;
165 end Task_Lock;
167 -----------------
168 -- Task_Unlock --
169 -----------------
171 procedure Task_Unlock is
172 Self_ID : constant Task_Id := STPO.Self;
174 begin
175 pragma Assert (Self_ID.Common.Global_Task_Lock_Nesting > 0);
176 Self_ID.Common.Global_Task_Lock_Nesting :=
177 Self_ID.Common.Global_Task_Lock_Nesting - 1;
179 if Self_ID.Common.Global_Task_Lock_Nesting = 0 then
180 STPO.Unlock (Global_Task_Lock'Access, Global_Lock => True);
181 end if;
182 end Task_Unlock;
184 ------------------
185 -- Task_Wrapper --
186 ------------------
188 -- The task wrapper is a procedure that is called first for each task
189 -- task body, and which in turn calls the compiler-generated task body
190 -- procedure. The wrapper's main job is to do initialization for the task.
192 -- The variable ID in the task wrapper is used to implement the Self
193 -- function on targets where there is a fast way to find the stack base
194 -- of the current thread, since it should be at a fixed offset from the
195 -- stack base.
197 procedure Task_Wrapper (Self_ID : Task_Id) is
198 ID : Task_Id := Self_ID;
199 pragma Volatile (ID);
200 pragma Warnings (Off, ID);
201 -- Variable used on some targets to implement a fast self. We turn off
202 -- warnings because a stand alone volatile constant has to be imported,
203 -- so we don't want warnings about ID not being referenced, and volatile
204 -- having no effect.
206 -- DO NOT delete ID. As noted, it is needed on some targets.
208 use type SSE.Storage_Offset;
210 Secondary_Stack : aliased SSE.Storage_Array
211 (1 .. Self_ID.Common.Compiler_Data.Pri_Stack_Info.Size *
212 SSE.Storage_Offset (Parameters.Sec_Stack_Percentage) / 100);
214 pragma Warnings (Off);
215 Secondary_Stack_Address : System.Address := Secondary_Stack'Address;
216 pragma Warnings (On);
217 -- Address of secondary stack. In the fixed secondary stack case, this
218 -- value is not modified, causing a warning, hence the bracketing with
219 -- Warnings (Off/On).
221 Cause : Cause_Of_Termination := Normal;
222 -- Indicates the reason why this task terminates. Normal corresponds to
223 -- a task terminating due to completing the last statement of its body.
224 -- If the task terminates because of an exception raised by the
225 -- execution of its task body, then Cause is set to Unhandled_Exception.
226 -- Aborts are not allowed in the restricted profile to which this file
227 -- belongs.
229 EO : Exception_Occurrence;
230 -- If the task terminates because of an exception raised by the
231 -- execution of its task body, then EO will contain the associated
232 -- exception occurrence. Otherwise, it will contain Null_Occurrence.
234 begin
235 if not Parameters.Sec_Stack_Dynamic then
236 Self_ID.Common.Compiler_Data.Sec_Stack_Addr :=
237 Secondary_Stack'Address;
238 SST.SS_Init (Secondary_Stack_Address, Integer (Secondary_Stack'Last));
239 end if;
241 -- Initialize low-level TCB components, that
242 -- cannot be initialized by the creator.
244 Enter_Task (Self_ID);
246 -- Call the task body procedure
248 begin
249 -- We are separating the following portion of the code in order to
250 -- place the exception handlers in a different block. In this way we
251 -- do not call Set_Jmpbuf_Address (which needs Self) before we set
252 -- Self in Enter_Task.
254 -- Note that in the case of Ravenscar HI-E where there are no
255 -- exception handlers, the exception handler is suppressed.
257 -- Call the task body procedure
259 Self_ID.Common.Task_Entry_Point (Self_ID.Common.Task_Arg);
261 -- Normal task termination
263 Cause := Normal;
264 Save_Occurrence (EO, Ada.Exceptions.Null_Occurrence);
266 exception
267 when E : others =>
269 -- Task terminating because of an unhandled exception
271 Cause := Unhandled_Exception;
272 Save_Occurrence (EO, E);
273 end;
275 -- Look for a fall-back handler
277 -- This package is part of the restricted run time which supports
278 -- neither task hierarchies (No_Task_Hierarchy) nor specific task
279 -- termination handlers (No_Specific_Termination_Handlers).
281 -- As specified in ARM C.7.3 par. 9/2, "the fall-back handler applies
282 -- only to the dependent tasks of the task". Hence, if the terminating
283 -- tasks (Self_ID) had a fall-back handler, it would not apply to
284 -- itself. This code is always executed by a task whose master is the
285 -- environment task (the task termination code for the environment task
286 -- is executed by SSL.Task_Termination_Handler), so the fall-back
287 -- handler to execute for this task can only be defined by its parent
288 -- (there is no grandparent).
290 declare
291 TH : Termination_Handler := null;
293 begin
294 if Single_Lock then
295 Lock_RTS;
296 end if;
298 Write_Lock (Self_ID.Common.Parent);
300 TH := Self_ID.Common.Parent.Common.Fall_Back_Handler;
302 Unlock (Self_ID.Common.Parent);
304 if Single_Lock then
305 Unlock_RTS;
306 end if;
308 -- Execute the task termination handler if we found it
310 if TH /= null then
311 TH.all (Cause, Self_ID, EO);
312 end if;
313 end;
315 Terminate_Task (Self_ID);
316 end Task_Wrapper;
318 -----------------------
319 -- Restricted GNARLI --
320 -----------------------
322 -----------------------------------
323 -- Activate_All_Tasks_Sequential --
324 -----------------------------------
326 procedure Activate_All_Tasks_Sequential is
327 begin
328 pragma Assert (Partition_Elaboration_Policy = 'S');
330 Activate_Tasks (Tasks_Activation_Chain);
331 Tasks_Activation_Chain := Null_Task;
332 end Activate_All_Tasks_Sequential;
334 -------------------------------
335 -- Activate_Restricted_Tasks --
336 -------------------------------
338 procedure Activate_Restricted_Tasks
339 (Chain_Access : Activation_Chain_Access) is
340 begin
341 if Partition_Elaboration_Policy = 'S' then
343 -- In sequential elaboration policy, the chain must be empty. This
344 -- procedure can be called if the unit has been compiled without
345 -- partition elaboration policy, but the partition has a sequential
346 -- elaboration policy.
348 pragma Assert (Chain_Access.T_ID = Null_Task);
349 null;
350 else
351 Activate_Tasks (Chain_Access.T_ID);
352 Chain_Access.T_ID := Null_Task;
353 end if;
354 end Activate_Restricted_Tasks;
356 --------------------
357 -- Activate_Tasks --
358 --------------------
360 -- Note that locks of activator and activated task are both locked here.
361 -- This is necessary because C.State and Self.Wait_Count have to be
362 -- synchronized. This is safe from deadlock because the activator is always
363 -- created before the activated task. That satisfies our
364 -- in-order-of-creation ATCB locking policy.
366 procedure Activate_Tasks (Chain : Task_Id) is
367 Self_ID : constant Task_Id := STPO.Self;
368 C : Task_Id;
369 Activate_Prio : System.Any_Priority;
370 Success : Boolean;
372 begin
373 pragma Assert (Self_ID = Environment_Task);
374 pragma Assert (Self_ID.Common.Wait_Count = 0);
376 if Single_Lock then
377 Lock_RTS;
378 end if;
380 -- Lock self, to prevent activated tasks from racing ahead before we
381 -- finish activating the chain.
383 Write_Lock (Self_ID);
385 -- Activate all the tasks in the chain. Creation of the thread of
386 -- control was deferred until activation. So create it now.
388 C := Chain;
389 while C /= null loop
390 if C.Common.State /= Terminated then
391 pragma Assert (C.Common.State = Unactivated);
393 Write_Lock (C);
395 Activate_Prio :=
396 (if C.Common.Base_Priority < Get_Priority (Self_ID)
397 then Get_Priority (Self_ID)
398 else C.Common.Base_Priority);
400 STPO.Create_Task
401 (C, Task_Wrapper'Address,
402 Parameters.Size_Type
403 (C.Common.Compiler_Data.Pri_Stack_Info.Size),
404 Activate_Prio, Success);
406 Self_ID.Common.Wait_Count := Self_ID.Common.Wait_Count + 1;
408 if Success then
409 C.Common.State := Runnable;
410 else
411 raise Program_Error;
412 end if;
414 Unlock (C);
415 end if;
417 C := C.Common.Activation_Link;
418 end loop;
420 Self_ID.Common.State := Activator_Sleep;
422 -- Wait for the activated tasks to complete activation. It is unsafe to
423 -- abort any of these tasks until the count goes to zero.
425 loop
426 exit when Self_ID.Common.Wait_Count = 0;
427 Sleep (Self_ID, Activator_Sleep);
428 end loop;
430 Self_ID.Common.State := Runnable;
431 Unlock (Self_ID);
433 if Single_Lock then
434 Unlock_RTS;
435 end if;
436 end Activate_Tasks;
438 ------------------------------------
439 -- Complete_Restricted_Activation --
440 ------------------------------------
442 -- As in several other places, the locks of the activator and activated
443 -- task are both locked here. This follows our deadlock prevention lock
444 -- ordering policy, since the activated task must be created after the
445 -- activator.
447 procedure Complete_Restricted_Activation is
448 Self_ID : constant Task_Id := STPO.Self;
449 Activator : constant Task_Id := Self_ID.Common.Activator;
451 begin
452 if Single_Lock then
453 Lock_RTS;
454 end if;
456 Write_Lock (Activator);
457 Write_Lock (Self_ID);
459 -- Remove dangling reference to Activator, since a task may outlive its
460 -- activator.
462 Self_ID.Common.Activator := null;
464 -- Wake up the activator, if it is waiting for a chain of tasks to
465 -- activate, and we are the last in the chain to complete activation
467 if Activator.Common.State = Activator_Sleep then
468 Activator.Common.Wait_Count := Activator.Common.Wait_Count - 1;
470 if Activator.Common.Wait_Count = 0 then
471 Wakeup (Activator, Activator_Sleep);
472 end if;
473 end if;
475 Unlock (Self_ID);
476 Unlock (Activator);
478 if Single_Lock then
479 Unlock_RTS;
480 end if;
482 -- After the activation, active priority should be the same as base
483 -- priority. We must unlock the Activator first, though, since it should
484 -- not wait if we have lower priority.
486 if Get_Priority (Self_ID) /= Self_ID.Common.Base_Priority then
487 Set_Priority (Self_ID, Self_ID.Common.Base_Priority);
488 end if;
489 end Complete_Restricted_Activation;
491 ------------------------------
492 -- Complete_Restricted_Task --
493 ------------------------------
495 procedure Complete_Restricted_Task is
496 begin
497 STPO.Self.Common.State := Terminated;
498 end Complete_Restricted_Task;
500 ----------------------------
501 -- Create_Restricted_Task --
502 ----------------------------
504 procedure Create_Restricted_Task
505 (Priority : Integer;
506 Stack_Address : System.Address;
507 Size : System.Parameters.Size_Type;
508 Task_Info : System.Task_Info.Task_Info_Type;
509 CPU : Integer;
510 State : Task_Procedure_Access;
511 Discriminants : System.Address;
512 Elaborated : Access_Boolean;
513 Task_Image : String;
514 Created_Task : Task_Id)
516 Self_ID : constant Task_Id := STPO.Self;
517 Base_Priority : System.Any_Priority;
518 Base_CPU : System.Multiprocessors.CPU_Range;
519 Success : Boolean;
520 Len : Integer;
522 begin
523 -- Stack is not preallocated on this target, so that Stack_Address must
524 -- be null.
526 pragma Assert (Stack_Address = Null_Address);
528 Base_Priority :=
529 (if Priority = Unspecified_Priority
530 then Self_ID.Common.Base_Priority
531 else System.Any_Priority (Priority));
533 -- Legal values of CPU are the special Unspecified_CPU value which is
534 -- inserted by the compiler for tasks without CPU aspect, and those in
535 -- the range of CPU_Range but no greater than Number_Of_CPUs. Otherwise
536 -- the task is defined to have failed, and it becomes a completed task
537 -- (RM D.16(14/3)).
539 if CPU /= Unspecified_CPU
540 and then (CPU < Integer (System.Multiprocessors.CPU_Range'First)
541 or else CPU > Integer (System.Multiprocessors.CPU_Range'Last)
542 or else CPU > Integer (System.Multiprocessors.Number_Of_CPUs))
543 then
544 raise Tasking_Error with "CPU not in range";
546 -- Normal CPU affinity
547 else
548 -- When the application code says nothing about the task affinity
549 -- (task without CPU aspect) then the compiler inserts the
550 -- Unspecified_CPU value which indicates to the run-time library that
551 -- the task will activate and execute on the same processor as its
552 -- activating task if the activating task is assigned a processor
553 -- (RM D.16(14/3)).
555 Base_CPU :=
556 (if CPU = Unspecified_CPU
557 then Self_ID.Common.Base_CPU
558 else System.Multiprocessors.CPU_Range (CPU));
559 end if;
561 if Single_Lock then
562 Lock_RTS;
563 end if;
565 Write_Lock (Self_ID);
567 -- With no task hierarchy, the parent of all non-Environment tasks that
568 -- are created must be the Environment task. Dispatching domains are
569 -- not allowed in Ravenscar, so the dispatching domain parameter will
570 -- always be null.
572 Initialize_ATCB
573 (Self_ID, State, Discriminants, Self_ID, Elaborated, Base_Priority,
574 Base_CPU, null, Task_Info, Size, Created_Task, Success);
576 -- If we do our job right then there should never be any failures, which
577 -- was probably said about the Titanic; so just to be safe, let's retain
578 -- this code for now
580 if not Success then
581 Unlock (Self_ID);
583 if Single_Lock then
584 Unlock_RTS;
585 end if;
587 raise Program_Error;
588 end if;
590 Created_Task.Entry_Calls (1).Self := Created_Task;
592 Len :=
593 Integer'Min (Created_Task.Common.Task_Image'Length, Task_Image'Length);
594 Created_Task.Common.Task_Image_Len := Len;
595 Created_Task.Common.Task_Image (1 .. Len) :=
596 Task_Image (Task_Image'First .. Task_Image'First + Len - 1);
598 Unlock (Self_ID);
600 if Single_Lock then
601 Unlock_RTS;
602 end if;
604 -- Create TSD as early as possible in the creation of a task, since it
605 -- may be used by the operation of Ada code within the task.
607 SSL.Create_TSD (Created_Task.Common.Compiler_Data);
608 end Create_Restricted_Task;
610 procedure Create_Restricted_Task
611 (Priority : Integer;
612 Stack_Address : System.Address;
613 Size : System.Parameters.Size_Type;
614 Task_Info : System.Task_Info.Task_Info_Type;
615 CPU : Integer;
616 State : Task_Procedure_Access;
617 Discriminants : System.Address;
618 Elaborated : Access_Boolean;
619 Chain : in out Activation_Chain;
620 Task_Image : String;
621 Created_Task : Task_Id)
623 begin
624 if Partition_Elaboration_Policy = 'S' then
626 -- A unit may have been compiled without partition elaboration
627 -- policy, and in this case the compiler will emit calls for the
628 -- default policy (concurrent). But if the partition policy is
629 -- sequential, activation must be deferred.
631 Create_Restricted_Task_Sequential
632 (Priority, Stack_Address, Size, Task_Info, CPU, State,
633 Discriminants, Elaborated, Task_Image, Created_Task);
635 else
636 Create_Restricted_Task
637 (Priority, Stack_Address, Size, Task_Info, CPU, State,
638 Discriminants, Elaborated, Task_Image, Created_Task);
640 -- Append this task to the activation chain
642 Created_Task.Common.Activation_Link := Chain.T_ID;
643 Chain.T_ID := Created_Task;
644 end if;
645 end Create_Restricted_Task;
647 ---------------------------------------
648 -- Create_Restricted_Task_Sequential --
649 ---------------------------------------
651 procedure Create_Restricted_Task_Sequential
652 (Priority : Integer;
653 Stack_Address : System.Address;
654 Size : System.Parameters.Size_Type;
655 Task_Info : System.Task_Info.Task_Info_Type;
656 CPU : Integer;
657 State : Task_Procedure_Access;
658 Discriminants : System.Address;
659 Elaborated : Access_Boolean;
660 Task_Image : String;
661 Created_Task : Task_Id) is
662 begin
663 Create_Restricted_Task (Priority, Stack_Address, Size, Task_Info,
664 CPU, State, Discriminants, Elaborated,
665 Task_Image, Created_Task);
667 -- Append this task to the activation chain
669 Created_Task.Common.Activation_Link := Tasks_Activation_Chain;
670 Tasks_Activation_Chain := Created_Task;
671 end Create_Restricted_Task_Sequential;
673 ---------------------------
674 -- Finalize_Global_Tasks --
675 ---------------------------
677 -- This is needed to support the compiler interface; it will only be called
678 -- by the Environment task. Instead, it will cause the Environment to block
679 -- forever, since none of the dependent tasks are expected to terminate
681 procedure Finalize_Global_Tasks is
682 Self_ID : constant Task_Id := STPO.Self;
684 begin
685 pragma Assert (Self_ID = STPO.Environment_Task);
687 if Single_Lock then
688 Lock_RTS;
689 end if;
691 -- Handle normal task termination by the environment task, but only for
692 -- the normal task termination. In the case of Abnormal and
693 -- Unhandled_Exception they must have been handled before, and the task
694 -- termination soft link must have been changed so the task termination
695 -- routine is not executed twice.
697 -- Note that in the "normal" implementation in s-tassta.adb the task
698 -- termination procedure for the environment task should be executed
699 -- after termination of library-level tasks. However, this
700 -- implementation is to be used when the Ravenscar restrictions are in
701 -- effect, and AI-394 says that if there is a fall-back handler set for
702 -- the partition it should be called when the first task (including the
703 -- environment task) attempts to terminate.
705 SSL.Task_Termination_Handler.all (Ada.Exceptions.Null_Occurrence);
707 Write_Lock (Self_ID);
708 Sleep (Self_ID, Master_Completion_Sleep);
709 Unlock (Self_ID);
711 if Single_Lock then
712 Unlock_RTS;
713 end if;
715 -- Should never return from Master Completion Sleep
717 raise Program_Error;
718 end Finalize_Global_Tasks;
720 ---------------------------
721 -- Restricted_Terminated --
722 ---------------------------
724 function Restricted_Terminated (T : Task_Id) return Boolean is
725 begin
726 return T.Common.State = Terminated;
727 end Restricted_Terminated;
729 --------------------
730 -- Terminate_Task --
731 --------------------
733 procedure Terminate_Task (Self_ID : Task_Id) is
734 begin
735 Self_ID.Common.State := Terminated;
736 end Terminate_Task;
738 --------------
739 -- Init_RTS --
740 --------------
742 procedure Init_RTS is
743 begin
744 Tasking.Initialize;
746 -- Initialize lock used to implement mutual exclusion between all tasks
748 STPO.Initialize_Lock (Global_Task_Lock'Access, STPO.Global_Task_Level);
750 -- Notify that the tasking run time has been elaborated so that
751 -- the tasking version of the soft links can be used.
753 SSL.Lock_Task := Task_Lock'Access;
754 SSL.Unlock_Task := Task_Unlock'Access;
755 SSL.Adafinal := Finalize_Global_Tasks'Access;
756 SSL.Get_Current_Excep := Get_Current_Excep'Access;
758 -- Initialize the tasking soft links (if not done yet) that are common
759 -- to the full and the restricted run times.
761 SSL.Tasking.Init_Tasking_Soft_Links;
762 end Init_RTS;
764 begin
765 Init_RTS;
766 end System.Tasking.Restricted.Stages;