Debian Codegraph @

gcc/ada/libgnarl/s-tarest.adb

raw
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-2025, 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 ------------------------------------------------------------------------------
31
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.
35
36 -- This is a simplified version of the System.Tasking.Stages package,
37 -- intended to be used in a restricted run time.
38
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.
41
42 with Ada.Exceptions;
43
44 with System.OS_Locks;
45 with System.Soft_Links.Tasking;
46 with System.Task_Primitives.Operations;
47
48 with System.Soft_Links;
49 -- Used for the non-tasking routines (*_NT) that refer to global data. They
50 -- are needed here before the tasking run time has been elaborated. used for
51 -- Create_TSD This package also provides initialization routines for task
52 -- specific data. The GNARL must call these to be sure that all non-tasking
53 -- Ada constructs will work.
54
55 package body System.Tasking.Restricted.Stages is
56
57 package STPO renames System.Task_Primitives.Operations;
58 package SSL renames System.Soft_Links;
59
60 use Ada.Exceptions;
61
62 use Task_Primitives.Operations;
63
64 Tasks_Activation_Chain : Task_Id;
65 -- Chain of all the tasks to activate
66
67 Global_Task_Lock : aliased System.OS_Locks.RTS_Lock;
68 -- This is a global lock; it is used to execute in mutual exclusion
69 -- from all other tasks. It is only used by Task_Lock and Task_Unlock.
70
71 -----------------------------------------------------------------
72 -- Tasking versions of services needed by non-tasking programs --
73 -----------------------------------------------------------------
74
75 function Get_Current_Excep return SSL.EOA;
76 -- Task-safe version of SSL.Get_Current_Excep
77
78 procedure Task_Lock;
79 -- Locks out other tasks. Preceding a section of code by Task_Lock and
80 -- following it by Task_Unlock creates a critical region. This is used
81 -- for ensuring that a region of non-tasking code (such as code used to
82 -- allocate memory) is tasking safe. Note that it is valid for calls to
83 -- Task_Lock/Task_Unlock to be nested, and this must work properly, i.e.
84 -- only the corresponding outer level Task_Unlock will actually unlock.
85
86 procedure Task_Unlock;
87 -- Releases lock previously set by call to Task_Lock. In the nested case,
88 -- all nested locks must be released before other tasks competing for the
89 -- tasking lock are released.
90
91 -----------------------
92 -- Local Subprograms --
93 -----------------------
94
95 procedure Task_Wrapper (Self_ID : Task_Id);
96 -- This is the procedure that is called by the GNULL from the
97 -- new context when a task is created. It waits for activation
98 -- and then calls the task body procedure. When the task body
99 -- procedure completes, it terminates the task.
100
101 procedure Terminate_Task (Self_ID : Task_Id);
102 -- Terminate the calling task.
103 -- This should only be called by the Task_Wrapper procedure.
104
105 procedure Create_Restricted_Task
106 (Priority : Integer;
107 Stack_Address : System.Address;
108 Stack_Size : System.Parameters.Size_Type;
109 Sec_Stack_Address : System.Secondary_Stack.SS_Stack_Ptr;
110 Sec_Stack_Size : System.Parameters.Size_Type;
111 Task_Info : System.Task_Info.Task_Info_Type;
112 CPU : Integer;
113 State : Task_Procedure_Access;
114 Discriminants : System.Address;
115 Elaborated : Access_Boolean;
116 Task_Image : String;
117 Created_Task : Task_Id);
118 -- Code shared between Create_Restricted_Task (the concurrent version) and
119 -- Create_Restricted_Task_Sequential. See comment of the former in the
120 -- specification of this package.
121
122 procedure Activate_Tasks (Chain : Task_Id);
123 -- Activate the list of tasks started by Chain
124
125 procedure Init_RTS;
126 -- This procedure performs the initialization of the GNARL.
127 -- It consists of initializing the environment task, global locks, and
128 -- installing tasking versions of certain operations used by the compiler.
129 -- Init_RTS is called during elaboration.
130
131 -----------------------
132 -- Get_Current_Excep --
133 -----------------------
134
135 function Get_Current_Excep return SSL.EOA is
136 begin
137 return STPO.Self.Common.Compiler_Data.Current_Excep'Access;
138 end Get_Current_Excep;
139
140 ---------------
141 -- Task_Lock --
142 ---------------
143
144 procedure Task_Lock is
145 Self_ID : constant Task_Id := STPO.Self;
146
147 begin
148 Self_ID.Common.Global_Task_Lock_Nesting :=
149 Self_ID.Common.Global_Task_Lock_Nesting + 1;
150
151 if Self_ID.Common.Global_Task_Lock_Nesting = 1 then
152 STPO.Write_Lock (Global_Task_Lock'Access);
153 end if;
154 end Task_Lock;
155
156 -----------------
157 -- Task_Unlock --
158 -----------------
159
160 procedure Task_Unlock is
161 Self_ID : constant Task_Id := STPO.Self;
162
163 begin
164 pragma Assert (Self_ID.Common.Global_Task_Lock_Nesting > 0);
165 Self_ID.Common.Global_Task_Lock_Nesting :=
166 Self_ID.Common.Global_Task_Lock_Nesting - 1;
167
168 if Self_ID.Common.Global_Task_Lock_Nesting = 0 then
169 STPO.Unlock (Global_Task_Lock'Access);
170 end if;
171 end Task_Unlock;
172
173 ------------------
174 -- Task_Wrapper --
175 ------------------
176
177 -- The task wrapper is a procedure that is called first for each task
178 -- task body, and which in turn calls the compiler-generated task body
179 -- procedure. The wrapper's main job is to do initialization for the task.
180
181 -- The variable ID in the task wrapper is used to implement the Self
182 -- function on targets where there is a fast way to find the stack base
183 -- of the current thread, since it should be at a fixed offset from the
184 -- stack base.
185
186 procedure Task_Wrapper (Self_ID : Task_Id) is
187 ID : Task_Id := Self_ID;
188 pragma Volatile (ID);
189 pragma Warnings (Off, ID);
190 -- Variable used on some targets to implement a fast self. We turn off
191 -- warnings because a stand alone volatile constant has to be imported,
192 -- so we don't want warnings about ID not being referenced, and volatile
193 -- having no effect.
194 --
195 -- DO NOT delete ID. As noted, it is needed on some targets.
196
197 Cause : Cause_Of_Termination := Normal;
198 -- Indicates the reason why this task terminates. Normal corresponds to
199 -- a task terminating due to completing the last statement of its body.
200 -- If the task terminates because of an exception raised by the
201 -- execution of its task body, then Cause is set to Unhandled_Exception.
202 -- Aborts are not allowed in the restricted profile to which this file
203 -- belongs.
204
205 EO : Exception_Occurrence;
206 -- If the task terminates because of an exception raised by the
207 -- execution of its task body, then EO will contain the associated
208 -- exception occurrence. Otherwise, it will contain Null_Occurrence.
209
210 begin
211 -- Initialize low-level TCB components, that cannot be initialized by
212 -- the creator.
213
214 Enter_Task (Self_ID);
215
216 -- Call the task body procedure
217
218 begin
219 -- We are separating the following portion of the code in order to
220 -- place the exception handlers in a different block. In this way we
221 -- do not call Set_Jmpbuf_Address (which needs Self) before we set
222 -- Self in Enter_Task.
223
224 -- Note that in the case of Ravenscar HI-E where there are no
225 -- exception handlers, the exception handler is suppressed.
226
227 -- Call the task body procedure
228
229 Self_ID.Common.Task_Entry_Point (Self_ID.Common.Task_Arg);
230
231 -- Normal task termination
232
233 Cause := Normal;
234 Save_Occurrence (EO, Ada.Exceptions.Null_Occurrence);
235
236 exception
237 when E : others =>
238
239 -- Task terminating because of an unhandled exception
240
241 Cause := Unhandled_Exception;
242 Save_Occurrence (EO, E);
243 end;
244
245 -- Look for a fall-back handler
246
247 -- This package is part of the restricted run time which supports
248 -- neither task hierarchies (No_Task_Hierarchy) nor specific task
249 -- termination handlers (No_Specific_Termination_Handlers).
250
251 -- As specified in ARM C.7.3 par. 9/2, "the fall-back handler applies
252 -- only to the dependent tasks of the task". Hence, if the terminating
253 -- tasks (Self_ID) had a fall-back handler, it would not apply to
254 -- itself. This code is always executed by a task whose master is the
255 -- environment task (the task termination code for the environment task
256 -- is executed by SSL.Task_Termination_Handler), so the fall-back
257 -- handler to execute for this task can only be defined by its parent
258 -- (there is no grandparent).
259
260 declare
261 TH : Termination_Handler := null;
262
263 begin
264 Write_Lock (Self_ID.Common.Parent);
265
266 TH := Self_ID.Common.Parent.Common.Fall_Back_Handler;
267
268 Unlock (Self_ID.Common.Parent);
269
270 -- Execute the task termination handler if we found it
271
272 if TH /= null then
273 TH.all (Cause, Self_ID, EO);
274 end if;
275 end;
276
277 Terminate_Task (Self_ID);
278 end Task_Wrapper;
279
280 -----------------------
281 -- Restricted GNARLI --
282 -----------------------
283
284 -----------------------------------
285 -- Activate_All_Tasks_Sequential --
286 -----------------------------------
287
288 procedure Activate_All_Tasks_Sequential is
289 begin
290 pragma Assert (Partition_Elaboration_Policy = 'S');
291
292 Activate_Tasks (Tasks_Activation_Chain);
293 Tasks_Activation_Chain := Null_Task;
294 end Activate_All_Tasks_Sequential;
295
296 -------------------------------
297 -- Activate_Restricted_Tasks --
298 -------------------------------
299
300 procedure Activate_Restricted_Tasks
301 (Chain_Access : Activation_Chain_Access) is
302 begin
303 if Partition_Elaboration_Policy = 'S' then
304
305 -- In sequential elaboration policy, the chain must be empty. This
306 -- procedure can be called if the unit has been compiled without
307 -- partition elaboration policy, but the partition has a sequential
308 -- elaboration policy.
309
310 pragma Assert (Chain_Access.T_ID = Null_Task);
311 null;
312 else
313 Activate_Tasks (Chain_Access.T_ID);
314 Chain_Access.T_ID := Null_Task;
315 end if;
316 end Activate_Restricted_Tasks;
317
318 --------------------
319 -- Activate_Tasks --
320 --------------------
321
322 -- Note that locks of activator and activated task are both locked here.
323 -- This is necessary because C.State and Self.Wait_Count have to be
324 -- synchronized. This is safe from deadlock because the activator is always
325 -- created before the activated task. That satisfies our
326 -- in-order-of-creation ATCB locking policy.
327
328 procedure Activate_Tasks (Chain : Task_Id) is
329 Self_ID : constant Task_Id := STPO.Self;
330 C : Task_Id;
331 Activate_Prio : System.Any_Priority;
332 Success : Boolean;
333
334 begin
335 pragma Assert (Self_ID = Environment_Task);
336 pragma Assert (Self_ID.Common.Wait_Count = 0);
337
338 -- Lock self, to prevent activated tasks from racing ahead before we
339 -- finish activating the chain.
340
341 Write_Lock (Self_ID);
342
343 -- Activate all the tasks in the chain. Creation of the thread of
344 -- control was deferred until activation. So create it now.
345
346 C := Chain;
347 while C /= null loop
348 if C.Common.State /= Terminated then
349 pragma Assert (C.Common.State = Unactivated);
350
351 Write_Lock (C);
352
353 Activate_Prio :=
354 (if C.Common.Base_Priority < Get_Priority (Self_ID)
355 then Get_Priority (Self_ID)
356 else C.Common.Base_Priority);
357
358 STPO.Create_Task
359 (C, Task_Wrapper'Address,
360 Parameters.Size_Type
361 (C.Common.Compiler_Data.Pri_Stack_Info.Size),
362 Activate_Prio, Success);
363
364 Self_ID.Common.Wait_Count := Self_ID.Common.Wait_Count + 1;
365
366 if Success then
367 C.Common.State := Runnable;
368 else
369 raise Program_Error;
370 end if;
371
372 Unlock (C);
373 end if;
374
375 C := C.Common.Activation_Link;
376 end loop;
377
378 Self_ID.Common.State := Activator_Sleep;
379
380 -- Wait for the activated tasks to complete activation. It is unsafe to
381 -- abort any of these tasks until the count goes to zero.
382
383 loop
384 exit when Self_ID.Common.Wait_Count = 0;
385 Sleep (Self_ID, Activator_Sleep);
386 end loop;
387
388 Self_ID.Common.State := Runnable;
389 Unlock (Self_ID);
390 end Activate_Tasks;
391
392 ------------------------------------
393 -- Complete_Restricted_Activation --
394 ------------------------------------
395
396 -- As in several other places, the locks of the activator and activated
397 -- task are both locked here. This follows our deadlock prevention lock
398 -- ordering policy, since the activated task must be created after the
399 -- activator.
400
401 procedure Complete_Restricted_Activation is
402 Self_ID : constant Task_Id := STPO.Self;
403 Activator : constant Task_Id := Self_ID.Common.Activator;
404
405 begin
406 Write_Lock (Activator);
407 Write_Lock (Self_ID);
408
409 -- Remove dangling reference to Activator, since a task may outlive its
410 -- activator.
411
412 Self_ID.Common.Activator := null;
413
414 -- Wake up the activator, if it is waiting for a chain of tasks to
415 -- activate, and we are the last in the chain to complete activation
416
417 if Activator.Common.State = Activator_Sleep then
418 Activator.Common.Wait_Count := Activator.Common.Wait_Count - 1;
419
420 if Activator.Common.Wait_Count = 0 then
421 Wakeup (Activator, Activator_Sleep);
422 end if;
423 end if;
424
425 Unlock (Self_ID);
426 Unlock (Activator);
427
428 -- After the activation, active priority should be the same as base
429 -- priority. We must unlock the Activator first, though, since it should
430 -- not wait if we have lower priority.
431
432 if Get_Priority (Self_ID) /= Self_ID.Common.Base_Priority then
433 Set_Priority (Self_ID, Self_ID.Common.Base_Priority);
434 end if;
435 end Complete_Restricted_Activation;
436
437 ------------------------------
438 -- Complete_Restricted_Task --
439 ------------------------------
440
441 procedure Complete_Restricted_Task is
442 begin
443 STPO.Self.Common.State := Terminated;
444 end Complete_Restricted_Task;
445
446 ----------------------------
447 -- Create_Restricted_Task --
448 ----------------------------
449
450 procedure Create_Restricted_Task
451 (Priority : Integer;
452 Stack_Address : System.Address;
453 Stack_Size : System.Parameters.Size_Type;
454 Sec_Stack_Address : System.Secondary_Stack.SS_Stack_Ptr;
455 Sec_Stack_Size : System.Parameters.Size_Type;
456 Task_Info : System.Task_Info.Task_Info_Type;
457 CPU : Integer;
458 State : Task_Procedure_Access;
459 Discriminants : System.Address;
460 Elaborated : Access_Boolean;
461 Task_Image : String;
462 Created_Task : Task_Id)
463 is
464 Self_ID : constant Task_Id := STPO.Self;
465 Base_Priority : System.Any_Priority;
466 Base_CPU : System.Multiprocessors.CPU_Range;
467 Success : Boolean;
468 Len : Integer;
469
470 begin
471 -- Stack is not preallocated on this target, so that Stack_Address must
472 -- be null.
473
474 pragma Assert (Stack_Address = Null_Address);
475
476 Base_Priority :=
477 (if Priority = Unspecified_Priority
478 then Self_ID.Common.Base_Priority
479 else System.Any_Priority (Priority));
480
481 -- Legal values of CPU are the special Unspecified_CPU value which is
482 -- inserted by the compiler for tasks without CPU aspect, and those in
483 -- the range of CPU_Range but no greater than Number_Of_CPUs. Otherwise
484 -- the task is defined to have failed, and it becomes a completed task
485 -- (RM D.16(14/3)).
486
487 if CPU /= Unspecified_CPU
488 and then (CPU < Integer (System.Multiprocessors.CPU_Range'First)
489 or else CPU > Integer (System.Multiprocessors.Number_Of_CPUs))
490 then
491 raise Tasking_Error with "CPU not in range";
492
493 -- Normal CPU affinity
494 else
495 -- When the application code says nothing about the task affinity
496 -- (task without CPU aspect) then the compiler inserts the
497 -- Unspecified_CPU value which indicates to the run-time library that
498 -- the task will activate and execute on the same processor as its
499 -- activating task if the activating task is assigned a processor
500 -- (RM D.16(14/3)).
501
502 Base_CPU :=
503 (if CPU = Unspecified_CPU
504 then Self_ID.Common.Base_CPU
505 else System.Multiprocessors.CPU_Range (CPU));
506 end if;
507
508 Write_Lock (Self_ID);
509
510 -- With no task hierarchy, the parent of all non-Environment tasks that
511 -- are created must be the Environment task. Dispatching domains are
512 -- not allowed in Ravenscar, so the dispatching domain parameter will
513 -- always be null.
514
515 Initialize_ATCB
516 (Self_ID, State, Discriminants, Self_ID, Elaborated, Base_Priority,
517 Base_CPU, CPU /= Unspecified_CPU, null, Task_Info, Stack_Size,
518 Created_Task, Success);
519
520 -- If we do our job right then there should never be any failures, which
521 -- was probably said about the Titanic; so just to be safe, let's retain
522 -- this code for now
523
524 if not Success then
525 Unlock (Self_ID);
526 raise Program_Error;
527 end if;
528
529 -- Only the first element of the Entry_Calls array is used when the
530 -- Ravenscar Profile is active, as no asynchronous transfer of control
531 -- is allowed.
532
533 Created_Task.Entry_Calls (Created_Task.Entry_Calls'First) :=
534 (Self => Created_Task,
535 Level => Created_Task.Entry_Calls'First,
536 others => <>);
537
538 -- Set task name
539
540 Len :=
541 Integer'Min (Created_Task.Common.Task_Image'Length, Task_Image'Length);
542 Created_Task.Common.Task_Image_Len := Len;
543 Created_Task.Common.Task_Image (1 .. Len) :=
544 Task_Image (Task_Image'First .. Task_Image'First + Len - 1);
545
546 Unlock (Self_ID);
547
548 -- Create TSD as early as possible in the creation of a task, since
549 -- it may be used by the operation of Ada code within the task. If the
550 -- compiler has not allocated a secondary stack, a stack will be
551 -- allocated fromt the binder generated pool.
552
553 SSL.Create_TSD
554 (Created_Task.Common.Compiler_Data,
555 Sec_Stack_Address,
556 Sec_Stack_Size);
557 end Create_Restricted_Task;
558
559 procedure Create_Restricted_Task
560 (Priority : Integer;
561 Stack_Address : System.Address;
562 Stack_Size : System.Parameters.Size_Type;
563 Sec_Stack_Address : System.Secondary_Stack.SS_Stack_Ptr;
564 Sec_Stack_Size : System.Parameters.Size_Type;
565 Task_Info : System.Task_Info.Task_Info_Type;
566 CPU : Integer;
567 State : Task_Procedure_Access;
568 Discriminants : System.Address;
569 Elaborated : Access_Boolean;
570 Chain : in out Activation_Chain;
571 Task_Image : String;
572 Created_Task : Task_Id)
573 is
574 begin
575 if Partition_Elaboration_Policy = 'S' then
576
577 -- A unit may have been compiled without partition elaboration
578 -- policy, and in this case the compiler will emit calls for the
579 -- default policy (concurrent). But if the partition policy is
580 -- sequential, activation must be deferred.
581
582 Create_Restricted_Task_Sequential
583 (Priority, Stack_Address, Stack_Size, Sec_Stack_Address,
584 Sec_Stack_Size, Task_Info, CPU, State, Discriminants, Elaborated,
585 Task_Image, Created_Task);
586
587 else
588 Create_Restricted_Task
589 (Priority, Stack_Address, Stack_Size, Sec_Stack_Address,
590 Sec_Stack_Size, Task_Info, CPU, State, Discriminants, Elaborated,
591 Task_Image, Created_Task);
592
593 -- Append this task to the activation chain
594
595 Created_Task.Common.Activation_Link := Chain.T_ID;
596 Chain.T_ID := Created_Task;
597 end if;
598 end Create_Restricted_Task;
599
600 ---------------------------------------
601 -- Create_Restricted_Task_Sequential --
602 ---------------------------------------
603
604 procedure Create_Restricted_Task_Sequential
605 (Priority : Integer;
606 Stack_Address : System.Address;
607 Stack_Size : System.Parameters.Size_Type;
608 Sec_Stack_Address : System.Secondary_Stack.SS_Stack_Ptr;
609 Sec_Stack_Size : System.Parameters.Size_Type;
610 Task_Info : System.Task_Info.Task_Info_Type;
611 CPU : Integer;
612 State : Task_Procedure_Access;
613 Discriminants : System.Address;
614 Elaborated : Access_Boolean;
615 Task_Image : String;
616 Created_Task : Task_Id)
617 is
618 begin
619 Create_Restricted_Task
620 (Priority, Stack_Address, Stack_Size, Sec_Stack_Address,
621 Sec_Stack_Size, Task_Info, CPU, State, Discriminants, Elaborated,
622 Task_Image, Created_Task);
623
624 -- Append this task to the activation chain
625
626 Created_Task.Common.Activation_Link := Tasks_Activation_Chain;
627 Tasks_Activation_Chain := Created_Task;
628 end Create_Restricted_Task_Sequential;
629
630 ---------------------------
631 -- Finalize_Global_Tasks --
632 ---------------------------
633
634 -- This is needed to support the compiler interface; it will only be called
635 -- by the Environment task. Instead, it will cause the Environment to block
636 -- forever, since none of the dependent tasks are expected to terminate
637
638 procedure Finalize_Global_Tasks is
639 Self_ID : constant Task_Id := STPO.Self;
640
641 begin
642 pragma Assert (Self_ID = STPO.Environment_Task);
643
644 -- Handle normal task termination by the environment task, but only for
645 -- the normal task termination. In the case of Abnormal and
646 -- Unhandled_Exception they must have been handled before, and the task
647 -- termination soft link must have been changed so the task termination
648 -- routine is not executed twice.
649
650 -- Note that in the "normal" implementation in s-tassta.adb the task
651 -- termination procedure for the environment task should be executed
652 -- after termination of library-level tasks. However, this
653 -- implementation is to be used when the Ravenscar restrictions are in
654 -- effect, and AI-394 says that if there is a fall-back handler set for
655 -- the partition it should be called when the first task (including the
656 -- environment task) attempts to terminate.
657
658 SSL.Task_Termination_Handler.all (Ada.Exceptions.Null_Occurrence);
659
660 Write_Lock (Self_ID);
661 Sleep (Self_ID, Master_Completion_Sleep);
662 Unlock (Self_ID);
663
664 -- Should never return from Master Completion Sleep
665
666 raise Program_Error;
667 end Finalize_Global_Tasks;
668
669 ---------------------------
670 -- Restricted_Terminated --
671 ---------------------------
672
673 function Restricted_Terminated (T : Task_Id) return Boolean is
674 begin
675 return T.Common.State = Terminated;
676 end Restricted_Terminated;
677
678 --------------------
679 -- Terminate_Task --
680 --------------------
681
682 procedure Terminate_Task (Self_ID : Task_Id) is
683 begin
684 Self_ID.Common.State := Terminated;
685 end Terminate_Task;
686
687 --------------
688 -- Init_RTS --
689 --------------
690
691 procedure Init_RTS is
692 begin
693 Tasking.Initialize;
694
695 -- Initialize lock used to implement mutual exclusion between all tasks
696
697 STPO.Initialize_Lock (Global_Task_Lock'Access, STPO.Global_Task_Level);
698
699 -- Notify that the tasking run time has been elaborated so that
700 -- the tasking version of the soft links can be used.
701
702 SSL.Lock_Task := Task_Lock'Access;
703 SSL.Unlock_Task := Task_Unlock'Access;
704 SSL.Adafinal := Finalize_Global_Tasks'Access;
705 SSL.Get_Current_Excep := Get_Current_Excep'Access;
706
707 -- Initialize the tasking soft links (if not done yet) that are common
708 -- to the full and the restricted run times.
709
710 SSL.Tasking.Init_Tasking_Soft_Links;
711 end Init_RTS;
712
713 begin
714 Init_RTS;
715 end System.Tasking.Restricted.Stages;