1 ------------------------------------------------------------------------------
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S --
9 -- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
11 -- GNARL is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNARL; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNARL was developed by the GNARL team at Florida State University. --
30 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
32 ------------------------------------------------------------------------------
34 -- This is a GNU/Linux (GNU/LinuxThreads) version of this package
36 -- This package contains all the GNULL primitives that interface directly
37 -- with the underlying OS.
40 -- Turn off polling, we do not want ATC polling to take place during
41 -- tasking operations. It causes infinite loops and other problems.
47 with System.Tasking.Debug;
48 -- used for Known_Tasks
50 with System.Interrupt_Management;
51 -- used for Keep_Unmasked
52 -- Abort_Task_Interrupt
55 with System.OS_Primitives;
56 -- used for Delay_Modes
58 with System.Soft_Links;
59 -- used for Abort_Defer/Undefer
61 -- We use System.Soft_Links instead of System.Tasking.Initialization
62 -- because the later is a higher level package that we shouldn't depend on.
63 -- For example when using the restricted run time, it is replaced by
64 -- System.Tasking.Restricted.Stages.
67 -- used for Raise_Exception
68 -- Raise_From_Signal_Handler
71 with Unchecked_Conversion;
72 with Unchecked_Deallocation;
74 package body System.Task_Primitives.Operations is
76 package SSL renames System.Soft_Links;
78 use System.Tasking.Debug;
81 use System.OS_Interface;
82 use System.Parameters;
83 use System.OS_Primitives;
89 -- The followings are logically constants, but need to be initialized
92 Single_RTS_Lock : aliased RTS_Lock;
93 -- This is a lock to allow only one thread of control in the RTS at
94 -- a time; it is used to execute in mutual exclusion from all other tasks.
95 -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List
97 ATCB_Key : aliased pthread_key_t;
98 -- Key used to find the Ada Task_Id associated with a thread
100 Environment_Task_Id : Task_Id;
101 -- A variable to hold Task_Id for the environment task
103 Unblocked_Signal_Mask : aliased sigset_t;
104 -- The set of signals that should be unblocked in all tasks
106 -- The followings are internal configuration constants needed
108 Next_Serial_Number : Task_Serial_Number := 100;
109 -- We start at 100, to reserve some special values for
110 -- using in error checking.
112 Time_Slice_Val : Integer;
113 pragma Import (C, Time_Slice_Val, "__gl_time_slice_val");
115 Dispatching_Policy : Character;
116 pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
118 -- The following are effectively constants, but they need to
119 -- be initialized by calling a pthread_ function.
121 Mutex_Attr : aliased pthread_mutexattr_t;
122 Cond_Attr : aliased pthread_condattr_t;
124 Foreign_Task_Elaborated : aliased Boolean := True;
125 -- Used to identified fake tasks (i.e., non-Ada Threads)
133 procedure Initialize (Environment_Task : Task_Id);
134 pragma Inline (Initialize);
135 -- Initialize various data needed by this package
137 function Is_Valid_Task return Boolean;
138 pragma Inline (Is_Valid_Task);
139 -- Does executing thread have a TCB?
141 procedure Set (Self_Id : Task_Id);
143 -- Set the self id for the current task
145 function Self return Task_Id;
146 pragma Inline (Self);
147 -- Return a pointer to the Ada Task Control Block of the calling task.
151 package body Specific is separate;
152 -- The body of this package is target specific
154 ---------------------------------
155 -- Support for foreign threads --
156 ---------------------------------
158 function Register_Foreign_Thread (Thread : Thread_Id) return Task_Id;
159 -- Allocate and Initialize a new ATCB for the current Thread
161 function Register_Foreign_Thread
162 (Thread : Thread_Id) return Task_Id is separate;
164 -----------------------
165 -- Local Subprograms --
166 -----------------------
168 subtype unsigned_long is Interfaces.C.unsigned_long;
170 procedure Abort_Handler (signo : Signal);
172 function To_pthread_t is new Unchecked_Conversion
173 (unsigned_long, System.OS_Interface.pthread_t);
179 procedure Abort_Handler (signo : Signal) is
180 pragma Unreferenced (signo);
182 Self_Id : constant Task_Id := Self;
183 Result : Interfaces.C.int;
184 Old_Set : aliased sigset_t;
187 if ZCX_By_Default and then GCC_ZCX_Support then
191 if Self_Id.Deferral_Level = 0
192 and then Self_Id.Pending_ATC_Level < Self_Id.ATC_Nesting_Level
193 and then not Self_Id.Aborting
195 Self_Id.Aborting := True;
197 -- Make sure signals used for RTS internal purpose are unmasked
199 Result := pthread_sigmask (SIG_UNBLOCK,
200 Unblocked_Signal_Mask'Unchecked_Access, Old_Set'Unchecked_Access);
201 pragma Assert (Result = 0);
203 raise Standard'Abort_Signal;
211 procedure Lock_RTS is
213 Write_Lock (Single_RTS_Lock'Access, Global_Lock => True);
220 procedure Unlock_RTS is
222 Unlock (Single_RTS_Lock'Access, Global_Lock => True);
229 -- The underlying thread system extends the memory (up to 2MB) when needed
231 procedure Stack_Guard (T : ST.Task_Id; On : Boolean) is
232 pragma Unreferenced (T);
233 pragma Unreferenced (On);
242 function Get_Thread_Id (T : ST.Task_Id) return OSI.Thread_Id is
244 return T.Common.LL.Thread;
251 function Self return Task_Id renames Specific.Self;
253 ---------------------
254 -- Initialize_Lock --
255 ---------------------
257 -- Note: mutexes and cond_variables needed per-task basis are
258 -- initialized in Initialize_TCB and the Storage_Error is
259 -- handled. Other mutexes (such as RTS_Lock, Memory_Lock...)
260 -- used in RTS is initialized before any status change of RTS.
261 -- Therefore rasing Storage_Error in the following routines
262 -- should be able to be handled safely.
264 procedure Initialize_Lock
265 (Prio : System.Any_Priority;
268 pragma Unreferenced (Prio);
270 Result : Interfaces.C.int;
272 Result := pthread_mutex_init (L, Mutex_Attr'Access);
274 pragma Assert (Result = 0 or else Result = ENOMEM);
276 if Result = ENOMEM then
277 Ada.Exceptions.Raise_Exception (Storage_Error'Identity,
278 "Failed to allocate a lock");
282 procedure Initialize_Lock (L : access RTS_Lock; Level : Lock_Level) is
283 pragma Unreferenced (Level);
285 Result : Interfaces.C.int;
288 Result := pthread_mutex_init (L, Mutex_Attr'Access);
290 pragma Assert (Result = 0 or else Result = ENOMEM);
292 if Result = ENOMEM then
301 procedure Finalize_Lock (L : access Lock) is
302 Result : Interfaces.C.int;
304 Result := pthread_mutex_destroy (L);
305 pragma Assert (Result = 0);
308 procedure Finalize_Lock (L : access RTS_Lock) is
309 Result : Interfaces.C.int;
311 Result := pthread_mutex_destroy (L);
312 pragma Assert (Result = 0);
319 procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is
320 Result : Interfaces.C.int;
322 Result := pthread_mutex_lock (L);
323 Ceiling_Violation := Result = EINVAL;
325 -- Assume the cause of EINVAL is a priority ceiling violation
327 pragma Assert (Result = 0 or else Result = EINVAL);
331 (L : access RTS_Lock;
332 Global_Lock : Boolean := False)
334 Result : Interfaces.C.int;
336 if not Single_Lock or else Global_Lock then
337 Result := pthread_mutex_lock (L);
338 pragma Assert (Result = 0);
342 procedure Write_Lock (T : Task_Id) is
343 Result : Interfaces.C.int;
345 if not Single_Lock then
346 Result := pthread_mutex_lock (T.Common.LL.L'Access);
347 pragma Assert (Result = 0);
355 procedure Read_Lock (L : access Lock; Ceiling_Violation : out Boolean) is
357 Write_Lock (L, Ceiling_Violation);
364 procedure Unlock (L : access Lock) is
365 Result : Interfaces.C.int;
367 Result := pthread_mutex_unlock (L);
368 pragma Assert (Result = 0);
371 procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is
372 Result : Interfaces.C.int;
374 if not Single_Lock or else Global_Lock then
375 Result := pthread_mutex_unlock (L);
376 pragma Assert (Result = 0);
380 procedure Unlock (T : Task_Id) is
381 Result : Interfaces.C.int;
383 if not Single_Lock then
384 Result := pthread_mutex_unlock (T.Common.LL.L'Access);
385 pragma Assert (Result = 0);
395 Reason : System.Tasking.Task_States)
397 pragma Unreferenced (Reason);
399 Result : Interfaces.C.int;
402 pragma Assert (Self_ID = Self);
405 Result := pthread_cond_wait
406 (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access);
408 Result := pthread_cond_wait
409 (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access);
412 -- EINTR is not considered a failure
414 pragma Assert (Result = 0 or else Result = EINTR);
421 -- This is for use within the run-time system, so abort is
422 -- assumed to be already deferred, and the caller should be
423 -- holding its own ATCB lock.
425 procedure Timed_Sleep
428 Mode : ST.Delay_Modes;
429 Reason : System.Tasking.Task_States;
430 Timedout : out Boolean;
431 Yielded : out Boolean)
433 pragma Unreferenced (Reason);
435 Check_Time : constant Duration := Monotonic_Clock;
437 Request : aliased timespec;
438 Result : Interfaces.C.int;
444 if Mode = Relative then
445 Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time;
447 Abs_Time := Duration'Min (Check_Time + Max_Sensible_Delay, Time);
450 if Abs_Time > Check_Time then
451 Request := To_Timespec (Abs_Time);
454 exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level
455 or else Self_ID.Pending_Priority_Change;
458 Result := pthread_cond_timedwait
459 (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access,
463 Result := pthread_cond_timedwait
464 (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access,
468 exit when Abs_Time <= Monotonic_Clock;
470 if Result = 0 or Result = EINTR then
471 -- somebody may have called Wakeup for us
476 pragma Assert (Result = ETIMEDOUT);
485 -- This is for use in implementing delay statements, so
486 -- we assume the caller is abort-deferred but is holding
489 procedure Timed_Delay
492 Mode : ST.Delay_Modes)
494 Check_Time : constant Duration := Monotonic_Clock;
496 Request : aliased timespec;
497 Result : Interfaces.C.int;
504 Write_Lock (Self_ID);
506 if Mode = Relative then
507 Abs_Time := Time + Check_Time;
509 Abs_Time := Duration'Min (Check_Time + Max_Sensible_Delay, Time);
512 if Abs_Time > Check_Time then
513 Request := To_Timespec (Abs_Time);
514 Self_ID.Common.State := Delay_Sleep;
517 if Self_ID.Pending_Priority_Change then
518 Self_ID.Pending_Priority_Change := False;
519 Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority;
520 Set_Priority (Self_ID, Self_ID.Common.Base_Priority);
523 exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level;
526 Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access,
527 Single_RTS_Lock'Access, Request'Access);
529 Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access,
530 Self_ID.Common.LL.L'Access, Request'Access);
533 exit when Abs_Time <= Monotonic_Clock;
535 pragma Assert (Result = 0 or else
536 Result = ETIMEDOUT or else
540 Self_ID.Common.State := Runnable;
549 Result := sched_yield;
552 ---------------------
553 -- Monotonic_Clock --
554 ---------------------
556 function Monotonic_Clock return Duration is
557 TV : aliased struct_timeval;
558 Result : Interfaces.C.int;
560 Result := gettimeofday (TV'Access, System.Null_Address);
561 pragma Assert (Result = 0);
562 return To_Duration (TV);
569 function RT_Resolution return Duration is
578 procedure Wakeup (T : Task_Id; Reason : System.Tasking.Task_States) is
579 pragma Unreferenced (Reason);
580 Result : Interfaces.C.int;
582 Result := pthread_cond_signal (T.Common.LL.CV'Access);
583 pragma Assert (Result = 0);
590 procedure Yield (Do_Yield : Boolean := True) is
591 Result : Interfaces.C.int;
592 pragma Unreferenced (Result);
595 Result := sched_yield;
603 procedure Set_Priority
605 Prio : System.Any_Priority;
606 Loss_Of_Inheritance : Boolean := False)
608 pragma Unreferenced (Loss_Of_Inheritance);
610 Result : Interfaces.C.int;
611 Param : aliased struct_sched_param;
614 T.Common.Current_Priority := Prio;
616 -- Priorities are in range 1 .. 99 on GNU/Linux, so we map
617 -- map 0 .. 31 to 1 .. 32
619 Param.sched_priority := Interfaces.C.int (Prio) + 1;
621 if Time_Slice_Val > 0 then
622 Result := pthread_setschedparam
623 (T.Common.LL.Thread, SCHED_RR, Param'Access);
625 elsif Dispatching_Policy = 'F' or else Time_Slice_Val = 0 then
626 Result := pthread_setschedparam
627 (T.Common.LL.Thread, SCHED_FIFO, Param'Access);
630 Param.sched_priority := 0;
631 Result := pthread_setschedparam
632 (T.Common.LL.Thread, SCHED_OTHER, Param'Access);
635 pragma Assert (Result = 0 or else Result = EPERM);
642 function Get_Priority (T : Task_Id) return System.Any_Priority is
644 return T.Common.Current_Priority;
651 procedure Enter_Task (Self_ID : Task_Id) is
653 Self_ID.Common.LL.Thread := pthread_self;
655 Specific.Set (Self_ID);
659 for J in Known_Tasks'Range loop
660 if Known_Tasks (J) = null then
661 Known_Tasks (J) := Self_ID;
662 Self_ID.Known_Tasks_Index := J;
674 function New_ATCB (Entry_Num : Task_Entry_Index) return Task_Id is
676 return new Ada_Task_Control_Block (Entry_Num);
683 function Is_Valid_Task return Boolean renames Specific.Is_Valid_Task;
685 -----------------------------
686 -- Register_Foreign_Thread --
687 -----------------------------
689 function Register_Foreign_Thread return Task_Id is
691 if Is_Valid_Task then
694 return Register_Foreign_Thread (pthread_self);
696 end Register_Foreign_Thread;
702 procedure Initialize_TCB (Self_ID : Task_Id; Succeeded : out Boolean) is
703 Result : Interfaces.C.int;
706 -- Give the task a unique serial number
708 Self_ID.Serial_Number := Next_Serial_Number;
709 Next_Serial_Number := Next_Serial_Number + 1;
710 pragma Assert (Next_Serial_Number /= 0);
712 Self_ID.Common.LL.Thread := To_pthread_t (-1);
714 if not Single_Lock then
715 Result := pthread_mutex_init (Self_ID.Common.LL.L'Access,
717 pragma Assert (Result = 0 or else Result = ENOMEM);
725 Result := pthread_cond_init (Self_ID.Common.LL.CV'Access,
727 pragma Assert (Result = 0 or else Result = ENOMEM);
732 if not Single_Lock then
733 Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access);
734 pragma Assert (Result = 0);
745 procedure Create_Task
747 Wrapper : System.Address;
748 Stack_Size : System.Parameters.Size_Type;
749 Priority : System.Any_Priority;
750 Succeeded : out Boolean)
752 Attributes : aliased pthread_attr_t;
753 Result : Interfaces.C.int;
756 Result := pthread_attr_init (Attributes'Access);
757 pragma Assert (Result = 0 or else Result = ENOMEM);
765 pthread_attr_setstacksize
766 (Attributes'Access, Interfaces.C.size_t (Stack_Size));
767 pragma Assert (Result = 0);
770 pthread_attr_setdetachstate
771 (Attributes'Access, PTHREAD_CREATE_DETACHED);
772 pragma Assert (Result = 0);
774 -- Since the initial signal mask of a thread is inherited from the
775 -- creator, and the Environment task has all its signals masked, we
776 -- do not need to manipulate caller's signal mask at this point.
777 -- All tasks in RTS will have All_Tasks_Mask initially.
779 Result := pthread_create
780 (T.Common.LL.Thread'Access,
782 Thread_Body_Access (Wrapper),
784 pragma Assert (Result = 0 or else Result = EAGAIN);
786 Succeeded := Result = 0;
788 Result := pthread_attr_destroy (Attributes'Access);
789 pragma Assert (Result = 0);
791 Set_Priority (T, Priority);
798 procedure Finalize_TCB (T : Task_Id) is
799 Result : Interfaces.C.int;
801 Is_Self : constant Boolean := T = Self;
803 procedure Free is new
804 Unchecked_Deallocation (Ada_Task_Control_Block, Task_Id);
807 if not Single_Lock then
808 Result := pthread_mutex_destroy (T.Common.LL.L'Access);
809 pragma Assert (Result = 0);
812 Result := pthread_cond_destroy (T.Common.LL.CV'Access);
813 pragma Assert (Result = 0);
815 if T.Known_Tasks_Index /= -1 then
816 Known_Tasks (T.Known_Tasks_Index) := null;
830 procedure Exit_Task is
839 procedure Abort_Task (T : Task_Id) is
840 Result : Interfaces.C.int;
842 Result := pthread_kill (T.Common.LL.Thread,
843 Signal (System.Interrupt_Management.Abort_Task_Interrupt));
844 pragma Assert (Result = 0);
851 procedure Initialize (S : in out Suspension_Object) is
852 Result : Interfaces.C.int;
854 -- Initialize internal state. It is always initialized to False (ARM
860 -- Initialize internal mutex
862 Result := pthread_mutex_init (S.L'Access, Mutex_Attr'Access);
864 pragma Assert (Result = 0 or else Result = ENOMEM);
866 if Result = ENOMEM then
870 -- Initialize internal condition variable
872 Result := pthread_cond_init (S.CV'Access, Cond_Attr'Access);
874 pragma Assert (Result = 0 or else Result = ENOMEM);
877 Result := pthread_mutex_destroy (S.L'Access);
878 pragma Assert (Result = 0);
880 if Result = ENOMEM then
890 procedure Finalize (S : in out Suspension_Object) is
891 Result : Interfaces.C.int;
893 -- Destroy internal mutex
895 Result := pthread_mutex_destroy (S.L'Access);
896 pragma Assert (Result = 0);
898 -- Destroy internal condition variable
900 Result := pthread_cond_destroy (S.CV'Access);
901 pragma Assert (Result = 0);
908 function Current_State (S : Suspension_Object) return Boolean is
910 -- We do not want to use lock on this read operation. State is marked
911 -- as Atomic so that we ensure that the value retrieved is correct.
920 procedure Set_False (S : in out Suspension_Object) is
921 Result : Interfaces.C.int;
925 Result := pthread_mutex_lock (S.L'Access);
926 pragma Assert (Result = 0);
930 Result := pthread_mutex_unlock (S.L'Access);
931 pragma Assert (Result = 0);
933 SSL.Abort_Undefer.all;
940 procedure Set_True (S : in out Suspension_Object) is
941 Result : Interfaces.C.int;
945 Result := pthread_mutex_lock (S.L'Access);
946 pragma Assert (Result = 0);
948 -- If there is already a task waiting on this suspension object then
949 -- we resume it, leaving the state of the suspension object to False,
950 -- as it is specified in ARM D.10 par. 9. Otherwise, it just leaves
951 -- the state to True.
957 Result := pthread_cond_signal (S.CV'Access);
958 pragma Assert (Result = 0);
963 Result := pthread_mutex_unlock (S.L'Access);
964 pragma Assert (Result = 0);
966 SSL.Abort_Undefer.all;
969 ------------------------
970 -- Suspend_Until_True --
971 ------------------------
973 procedure Suspend_Until_True (S : in out Suspension_Object) is
974 Result : Interfaces.C.int;
978 Result := pthread_mutex_lock (S.L'Access);
979 pragma Assert (Result = 0);
982 -- Program_Error must be raised upon calling Suspend_Until_True
983 -- if another task is already waiting on that suspension object
984 -- (ARM D.10 par. 10).
986 Result := pthread_mutex_unlock (S.L'Access);
987 pragma Assert (Result = 0);
989 SSL.Abort_Undefer.all;
993 -- Suspend the task if the state is False. Otherwise, the task
994 -- continues its execution, and the state of the suspension object
995 -- is set to False (ARM D.10 par. 9).
1001 Result := pthread_cond_wait (S.CV'Access, S.L'Access);
1004 Result := pthread_mutex_unlock (S.L'Access);
1005 pragma Assert (Result = 0);
1007 SSL.Abort_Undefer.all;
1009 end Suspend_Until_True;
1017 function Check_Exit (Self_ID : ST.Task_Id) return Boolean is
1018 pragma Unreferenced (Self_ID);
1023 --------------------
1024 -- Check_No_Locks --
1025 --------------------
1027 function Check_No_Locks (Self_ID : ST.Task_Id) return Boolean is
1028 pragma Unreferenced (Self_ID);
1033 ----------------------
1034 -- Environment_Task --
1035 ----------------------
1037 function Environment_Task return Task_Id is
1039 return Environment_Task_Id;
1040 end Environment_Task;
1046 function Suspend_Task
1048 Thread_Self : Thread_Id) return Boolean
1051 if T.Common.LL.Thread /= Thread_Self then
1052 return pthread_kill (T.Common.LL.Thread, SIGSTOP) = 0;
1062 function Resume_Task
1064 Thread_Self : Thread_Id) return Boolean
1067 if T.Common.LL.Thread /= Thread_Self then
1068 return pthread_kill (T.Common.LL.Thread, SIGCONT) = 0;
1078 procedure Initialize (Environment_Task : Task_Id) is
1079 act : aliased struct_sigaction;
1080 old_act : aliased struct_sigaction;
1081 Tmp_Set : aliased sigset_t;
1082 Result : Interfaces.C.int;
1085 (Int : System.Interrupt_Management.Interrupt_ID) return Character;
1086 pragma Import (C, State, "__gnat_get_interrupt_state");
1087 -- Get interrupt state. Defined in a-init.c
1088 -- The input argument is the interrupt number,
1089 -- and the result is one of the following:
1091 Default : constant Character := 's';
1092 -- 'n' this interrupt not set by any Interrupt_State pragma
1093 -- 'u' Interrupt_State pragma set state to User
1094 -- 'r' Interrupt_State pragma set state to Runtime
1095 -- 's' Interrupt_State pragma set state to System (use "default"
1099 Environment_Task_Id := Environment_Task;
1101 Interrupt_Management.Initialize;
1103 -- Prepare the set of signals that should be unblocked in all tasks
1105 Result := sigemptyset (Unblocked_Signal_Mask'Access);
1106 pragma Assert (Result = 0);
1108 for J in Interrupt_Management.Interrupt_ID loop
1109 if System.Interrupt_Management.Keep_Unmasked (J) then
1110 Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
1111 pragma Assert (Result = 0);
1115 Result := pthread_mutexattr_init (Mutex_Attr'Access);
1116 pragma Assert (Result = 0);
1118 Result := pthread_condattr_init (Cond_Attr'Access);
1119 pragma Assert (Result = 0);
1121 Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
1123 -- Initialize the global RTS lock
1125 Specific.Initialize (Environment_Task);
1127 Enter_Task (Environment_Task);
1129 -- Install the abort-signal handler
1131 if State (System.Interrupt_Management.Abort_Task_Interrupt)
1135 act.sa_handler := Abort_Handler'Address;
1137 Result := sigemptyset (Tmp_Set'Access);
1138 pragma Assert (Result = 0);
1139 act.sa_mask := Tmp_Set;
1143 (Signal (Interrupt_Management.Abort_Task_Interrupt),
1144 act'Unchecked_Access,
1145 old_act'Unchecked_Access);
1146 pragma Assert (Result = 0);
1150 end System.Task_Primitives.Operations;