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 --
10 -- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
12 -- GNARL is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNARL; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
30 -- GNARL was developed by the GNARL team at Florida State University. It is --
31 -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). --
33 ------------------------------------------------------------------------------
35 -- This is a GNU/Linux (GNU/LinuxThreads) version of this package
37 -- This package contains all the GNULL primitives that interface directly
38 -- with the underlying OS.
41 -- Turn off polling, we do not want ATC polling to take place during
42 -- tasking operations. It causes infinite loops and other problems.
44 with System
.Tasking
.Debug
;
45 -- used for Known_Tasks
51 with System
.Interrupt_Management
;
52 -- used for Keep_Unmasked
53 -- Abort_Task_Interrupt
56 with System
.Interrupt_Management
.Operations
;
57 -- used for Set_Interrupt_Mask
59 pragma Elaborate_All
(System
.Interrupt_Management
.Operations
);
61 with System
.Parameters
;
65 -- used for Ada_Task_Control_Block
69 -- used for Raise_Exception
70 -- Raise_From_Signal_Handler
73 with System
.Soft_Links
;
74 -- used for Defer/Undefer_Abort
76 -- Note that we do not use System.Tasking.Initialization directly since
77 -- this is a higher level package that we shouldn't depend on. For example
78 -- when using the restricted run time, it is replaced by
79 -- System.Tasking.Restricted.Initialization
81 with System
.OS_Primitives
;
82 -- used for Delay_Modes
84 with System
.Soft_Links
;
85 -- used for Get_Machine_State_Addr
87 with Unchecked_Conversion
;
88 with Unchecked_Deallocation
;
90 package body System
.Task_Primitives
.Operations
is
92 use System
.Tasking
.Debug
;
95 use System
.OS_Interface
;
96 use System
.Parameters
;
97 use System
.OS_Primitives
;
99 package SSL
renames System
.Soft_Links
;
105 Max_Stack_Size
: constant := 2000 * 1024;
106 -- GNU/LinuxThreads does not return an error value when requesting
107 -- a task stack size which is too large, so we have to check this
110 -- The followings are logically constants, but need to be initialized
113 Single_RTS_Lock
: aliased RTS_Lock
;
114 -- This is a lock to allow only one thread of control in the RTS at
115 -- a time; it is used to execute in mutual exclusion from all other tasks.
116 -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List
118 Environment_Task_ID
: Task_ID
;
119 -- A variable to hold Task_ID for the environment task.
121 Unblocked_Signal_Mask
: aliased sigset_t
;
122 -- The set of signals that should unblocked in all tasks
124 -- The followings are internal configuration constants needed.
125 Priority_Ceiling_Emulation
: constant Boolean := True;
127 Next_Serial_Number
: Task_Serial_Number
:= 100;
128 -- We start at 100, to reserve some special values for
129 -- using in error checking.
130 -- The following are internal configuration constants needed.
132 Time_Slice_Val
: Integer;
133 pragma Import
(C
, Time_Slice_Val
, "__gl_time_slice_val");
135 Dispatching_Policy
: Character;
136 pragma Import
(C
, Dispatching_Policy
, "__gl_task_dispatching_policy");
138 FIFO_Within_Priorities
: constant Boolean := Dispatching_Policy
= 'F';
139 -- Indicates whether FIFO_Within_Priorities is set.
141 -- The following are effectively constants, but they need to
142 -- be initialized by calling a pthread_ function.
144 Mutex_Attr
: aliased pthread_mutexattr_t
;
145 Cond_Attr
: aliased pthread_condattr_t
;
147 -----------------------
148 -- Local Subprograms --
149 -----------------------
151 subtype unsigned_short
is Interfaces
.C
.unsigned_short
;
152 subtype unsigned_long
is Interfaces
.C
.unsigned_long
;
154 procedure Abort_Handler
168 trapno
: unsigned_long
;
172 eflags
: unsigned_long
;
173 esp_at_signal
: unsigned_long
;
175 fpstate
: System
.Address
;
176 oldmask
: unsigned_long
;
177 cr2
: unsigned_long
);
179 function To_Task_ID
is new Unchecked_Conversion
(System
.Address
, Task_ID
);
181 function To_Address
is new Unchecked_Conversion
(Task_ID
, System
.Address
);
183 function To_pthread_t
is new Unchecked_Conversion
184 (Integer, System
.OS_Interface
.pthread_t
);
192 procedure Initialize
(Environment_Task
: Task_ID
);
193 pragma Inline
(Initialize
);
194 -- Initialize various data needed by this package.
196 procedure Set
(Self_Id
: Task_ID
);
198 -- Set the self id for the current task.
200 function Self
return Task_ID
;
201 pragma Inline
(Self
);
202 -- Return a pointer to the Ada Task Control Block of the calling task.
206 package body Specific
is separate;
207 -- The body of this package is target specific.
213 -- Target-dependent binding of inter-thread Abort signal to
214 -- the raising of the Abort_Signal exception.
216 -- The technical issues and alternatives here are essentially
217 -- the same as for raising exceptions in response to other
218 -- signals (e.g. Storage_Error). See code and comments in
219 -- the package body System.Interrupt_Management.
221 -- Some implementations may not allow an exception to be propagated
222 -- out of a handler, and others might leave the signal or
223 -- interrupt that invoked this handler masked after the exceptional
224 -- return to the application code.
226 -- GNAT exceptions are originally implemented using setjmp()/longjmp().
227 -- On most UNIX systems, this will allow transfer out of a signal handler,
228 -- which is usually the only mechanism available for implementing
229 -- asynchronous handlers of this kind. However, some
230 -- systems do not restore the signal mask on longjmp(), leaving the
231 -- abort signal masked.
233 -- Alternative solutions include:
235 -- 1. Change the PC saved in the system-dependent Context
236 -- parameter to point to code that raises the exception.
237 -- Normal return from this handler will then raise
238 -- the exception after the mask and other system state has
239 -- been restored (see example below).
240 -- 2. Use siglongjmp()/sigsetjmp() to implement exceptions.
241 -- 3. Unmask the signal in the Abortion_Signal exception handler
244 -- Note that with the new exception mechanism, it is not correct to
245 -- simply "raise" an exception from a signal handler, that's why we
246 -- use Raise_From_Signal_Handler
248 procedure Abort_Handler
262 trapno
: unsigned_long
;
266 eflags
: unsigned_long
;
267 esp_at_signal
: unsigned_long
;
269 fpstate
: System
.Address
;
270 oldmask
: unsigned_long
;
273 Self_Id
: Task_ID
:= Self
;
274 Result
: Interfaces
.C
.int
;
275 Old_Set
: aliased sigset_t
;
277 function To_Machine_State_Ptr
is new
278 Unchecked_Conversion
(Address
, Machine_State_Ptr
);
280 -- These are not directly visible
282 procedure Raise_From_Signal_Handler
283 (E
: Ada
.Exceptions
.Exception_Id
;
286 (Ada
, Raise_From_Signal_Handler
,
287 "ada__exceptions__raise_from_signal_handler");
288 pragma No_Return
(Raise_From_Signal_Handler
);
290 mstate
: Machine_State_Ptr
;
291 message
: aliased constant String := "" & ASCII
.Nul
;
292 -- a null terminated String.
295 if Self_Id
.Deferral_Level
= 0
296 and then Self_Id
.Pending_ATC_Level
< Self_Id
.ATC_Nesting_Level
297 and then not Self_Id
.Aborting
299 Self_Id
.Aborting
:= True;
301 -- Make sure signals used for RTS internal purpose are unmasked
303 Result
:= pthread_sigmask
(SIG_UNBLOCK
,
304 Unblocked_Signal_Mask
'Unchecked_Access, Old_Set
'Unchecked_Access);
305 pragma Assert
(Result
= 0);
307 mstate
:= To_Machine_State_Ptr
(SSL
.Get_Machine_State_Addr
.all);
310 mstate
.esp
:= esp_at_signal
;
315 Raise_From_Signal_Handler
316 (Standard
'Abort_Signal'Identity, message'Address);
324 procedure Lock_RTS is
326 Write_Lock (Single_RTS_Lock'Access, Global_Lock => True);
333 procedure Unlock_RTS is
335 Unlock (Single_RTS_Lock'Access, Global_Lock => True);
342 -- The underlying thread system extends the memory (up to 2MB) when
345 procedure Stack_Guard (T : ST.Task_ID; On : Boolean) is
354 function Get_Thread_Id (T : ST.Task_ID) return OSI.Thread_Id is
356 return T.Common.LL.Thread;
363 function Self return Task_ID renames Specific.Self;
365 ---------------------
366 -- Initialize_Lock --
367 ---------------------
369 -- Note: mutexes and cond_variables needed per-task basis are
370 -- initialized in Initialize_TCB and the Storage_Error is
371 -- handled. Other mutexes (such as RTS_Lock, Memory_Lock...)
372 -- used in RTS is initialized before any status change of RTS.
373 -- Therefore rasing Storage_Error in the following routines
374 -- should be able to be handled safely.
376 procedure Initialize_Lock
377 (Prio : System.Any_Priority;
380 Result : Interfaces.C.int;
382 if Priority_Ceiling_Emulation then
386 Result := pthread_mutex_init (L.L'Access, Mutex_Attr'Access);
388 pragma Assert (Result = 0 or else Result = ENOMEM);
390 if Result = ENOMEM then
391 Ada.Exceptions.Raise_Exception (Storage_Error'Identity,
392 "Failed to allocate a lock");
396 procedure Initialize_Lock (L : access RTS_Lock; Level : Lock_Level) is
397 Result : Interfaces.C.int;
400 Result := pthread_mutex_init (L, Mutex_Attr'Access);
402 pragma Assert (Result = 0 or else Result = ENOMEM);
404 if Result = ENOMEM then
413 procedure Finalize_Lock (L : access Lock) is
414 Result : Interfaces.C.int;
417 Result := pthread_mutex_destroy (L.L'Access);
418 pragma Assert (Result = 0);
421 procedure Finalize_Lock (L : access RTS_Lock) is
422 Result : Interfaces.C.int;
425 Result := pthread_mutex_destroy (L);
426 pragma Assert (Result = 0);
433 procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is
434 Result : Interfaces.C.int;
436 if Priority_Ceiling_Emulation then
438 Self_ID : constant Task_ID := Self;
440 if Self_ID.Common.LL.Active_Priority > L.Ceiling then
441 Ceiling_Violation := True;
444 L.Saved_Priority := Self_ID.Common.LL.Active_Priority;
445 if Self_ID.Common.LL.Active_Priority < L.Ceiling then
446 Self_ID.Common.LL.Active_Priority := L.Ceiling;
448 Result := pthread_mutex_lock (L.L'Access);
449 pragma Assert (Result = 0);
450 Ceiling_Violation := False;
453 Result := pthread_mutex_lock (L.L'Access);
454 Ceiling_Violation := Result = EINVAL;
455 -- assumes the cause of EINVAL is a priority ceiling violation
456 pragma Assert (Result = 0 or else Result = EINVAL);
461 (L : access RTS_Lock; Global_Lock : Boolean := False)
463 Result : Interfaces.C.int;
465 if not Single_Lock or else Global_Lock then
466 Result := pthread_mutex_lock (L);
467 pragma Assert (Result = 0);
471 procedure Write_Lock (T : Task_ID) is
472 Result : Interfaces.C.int;
474 if not Single_Lock then
475 Result := pthread_mutex_lock (T.Common.LL.L'Access);
476 pragma Assert (Result = 0);
484 procedure Read_Lock (L : access Lock; Ceiling_Violation : out Boolean) is
486 Write_Lock (L, Ceiling_Violation);
493 procedure Unlock (L : access Lock) is
494 Result : Interfaces.C.int;
496 if Priority_Ceiling_Emulation then
498 Self_ID : constant Task_ID := Self;
500 Result := pthread_mutex_unlock (L.L'Access);
501 pragma Assert (Result = 0);
502 if Self_ID.Common.LL.Active_Priority > L.Saved_Priority then
503 Self_ID.Common.LL.Active_Priority := L.Saved_Priority;
507 Result := pthread_mutex_unlock (L.L'Access);
508 pragma Assert (Result = 0);
512 procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is
513 Result : Interfaces.C.int;
515 if not Single_Lock or else Global_Lock then
516 Result := pthread_mutex_unlock (L);
517 pragma Assert (Result = 0);
521 procedure Unlock (T : Task_ID) is
522 Result : Interfaces.C.int;
524 if not Single_Lock then
525 Result := pthread_mutex_unlock (T.Common.LL.L'Access);
526 pragma Assert (Result = 0);
536 Reason : System.Tasking.Task_States)
538 Result : Interfaces.C.int;
540 pragma Assert (Self_ID = Self);
543 Result := pthread_cond_wait
544 (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access);
546 Result := pthread_cond_wait
547 (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access);
550 -- EINTR is not considered a failure.
551 pragma Assert (Result = 0 or else Result = EINTR);
558 -- This is for use within the run-time system, so abort is
559 -- assumed to be already deferred, and the caller should be
560 -- holding its own ATCB lock.
562 procedure Timed_Sleep
565 Mode : ST.Delay_Modes;
566 Reason : System.Tasking.Task_States;
567 Timedout : out Boolean;
568 Yielded : out Boolean)
570 Check_Time : constant Duration := Monotonic_Clock;
572 Request : aliased timespec;
573 Result : Interfaces.C.int;
578 if Mode = Relative then
579 Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time;
581 Abs_Time := Duration'Min (Check_Time + Max_Sensible_Delay, Time);
584 if Abs_Time > Check_Time then
585 Request := To_Timespec (Abs_Time);
588 exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level
589 or else Self_ID.Pending_Priority_Change;
592 Result := pthread_cond_timedwait
593 (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access,
597 Result := pthread_cond_timedwait
598 (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access,
602 exit when Abs_Time <= Monotonic_Clock;
604 if Result = 0 or Result = EINTR then
605 -- somebody may have called Wakeup for us
610 pragma Assert (Result = ETIMEDOUT);
619 -- This is for use in implementing delay statements, so
620 -- we assume the caller is abort-deferred but is holding
623 procedure Timed_Delay
626 Mode : ST.Delay_Modes)
628 Check_Time : constant Duration := Monotonic_Clock;
630 Request : aliased timespec;
631 Result : Interfaces.C.int;
634 -- Only the little window between deferring abort and
635 -- locking Self_ID is the reason we need to
636 -- check for pending abort and priority change below! :(
644 Write_Lock (Self_ID);
646 if Mode = Relative then
647 Abs_Time := Time + Check_Time;
649 Abs_Time := Duration'Min (Check_Time + Max_Sensible_Delay, Time);
652 if Abs_Time > Check_Time then
653 Request := To_Timespec (Abs_Time);
654 Self_ID.Common.State := Delay_Sleep;
657 if Self_ID.Pending_Priority_Change then
658 Self_ID.Pending_Priority_Change := False;
659 Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority;
660 Set_Priority (Self_ID, Self_ID.Common.Base_Priority);
663 exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level;
666 Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access,
667 Single_RTS_Lock'Access, Request'Access);
669 Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access,
670 Self_ID.Common.LL.L'Access, Request'Access);
673 exit when Abs_Time <= Monotonic_Clock;
675 pragma Assert (Result = 0 or else
676 Result = ETIMEDOUT or else
680 Self_ID.Common.State := Runnable;
689 Result := sched_yield;
690 SSL.Abort_Undefer.all;
693 ---------------------
694 -- Monotonic_Clock --
695 ---------------------
697 function Monotonic_Clock return Duration is
698 TV : aliased struct_timeval;
699 Result : Interfaces.C.int;
702 Result := gettimeofday (TV'Access, System.Null_Address);
703 pragma Assert (Result = 0);
704 return To_Duration (TV);
711 function RT_Resolution return Duration is
720 procedure Wakeup (T : Task_ID; Reason : System.Tasking.Task_States) is
721 Result : Interfaces.C.int;
724 Result := pthread_cond_signal (T.Common.LL.CV'Access);
725 pragma Assert (Result = 0);
732 procedure Yield (Do_Yield : Boolean := True) is
733 Result : Interfaces.C.int;
737 Result := sched_yield;
745 procedure Set_Priority
747 Prio : System.Any_Priority;
748 Loss_Of_Inheritance : Boolean := False)
750 Result : Interfaces.C.int;
751 Param : aliased struct_sched_param;
754 T.Common.Current_Priority := Prio;
756 if Priority_Ceiling_Emulation then
757 if T.Common.LL.Active_Priority < Prio then
758 T.Common.LL.Active_Priority := Prio;
762 -- Priorities are in range 1 .. 99 on GNU/Linux, so we map
763 -- map 0 .. 31 to 1 .. 32
765 Param.sched_priority := Interfaces.C.int (Prio) + 1;
767 if Time_Slice_Val > 0 then
768 Result := pthread_setschedparam
769 (T.Common.LL.Thread, SCHED_RR, Param'Access);
771 elsif FIFO_Within_Priorities or else Time_Slice_Val = 0 then
772 Result := pthread_setschedparam
773 (T.Common.LL.Thread, SCHED_FIFO, Param'Access);
776 Result := pthread_setschedparam
777 (T.Common.LL.Thread, SCHED_OTHER, Param'Access);
780 pragma Assert (Result = 0 or else Result = EPERM);
787 function Get_Priority (T : Task_ID) return System.Any_Priority is
789 return T.Common.Current_Priority;
796 procedure Enter_Task (Self_ID : Task_ID) is
798 Self_ID.Common.LL.Thread := pthread_self;
800 Specific.Set (Self_ID);
804 for J in Known_Tasks'Range loop
805 if Known_Tasks (J) = null then
806 Known_Tasks (J) := Self_ID;
807 Self_ID.Known_Tasks_Index := J;
819 function New_ATCB (Entry_Num : Task_Entry_Index) return Task_ID is
821 return new Ada_Task_Control_Block (Entry_Num);
828 procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is
829 Result : Interfaces.C.int;
832 -- Give the task a unique serial number.
834 Self_ID.Serial_Number := Next_Serial_Number;
835 Next_Serial_Number := Next_Serial_Number + 1;
836 pragma Assert (Next_Serial_Number /= 0);
838 Self_ID.Common.LL.Thread := To_pthread_t (-1);
840 if not Single_Lock then
841 Result := pthread_mutex_init (Self_ID.Common.LL.L'Access,
843 pragma Assert (Result = 0 or else Result = ENOMEM);
851 Result := pthread_cond_init (Self_ID.Common.LL.CV'Access,
853 pragma Assert (Result = 0 or else Result = ENOMEM);
858 if not Single_Lock then
859 Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access);
860 pragma Assert (Result = 0);
871 procedure Create_Task
873 Wrapper : System.Address;
874 Stack_Size : System.Parameters.Size_Type;
875 Priority : System.Any_Priority;
876 Succeeded : out Boolean)
878 Attributes : aliased pthread_attr_t;
879 Result : Interfaces.C.int;
881 function Thread_Body_Access is new
882 Unchecked_Conversion (System.Address, Thread_Body);
885 Result := pthread_attr_init (Attributes'Access);
886 pragma Assert (Result = 0 or else Result = ENOMEM);
888 if Result /= 0 or else Stack_Size > Max_Stack_Size then
893 Result := pthread_attr_setdetachstate
894 (Attributes'Access, PTHREAD_CREATE_DETACHED);
895 pragma Assert (Result = 0);
897 -- Since the initial signal mask of a thread is inherited from the
898 -- creator, and the Environment task has all its signals masked, we
899 -- do not need to manipulate caller's signal mask at this point.
900 -- All tasks in RTS will have All_Tasks_Mask initially.
902 Result := pthread_create
903 (T.Common.LL.Thread'Access,
905 Thread_Body_Access (Wrapper),
907 pragma Assert (Result = 0 or else Result = EAGAIN);
909 Succeeded := Result = 0;
911 Result := pthread_attr_destroy (Attributes'Access);
912 pragma Assert (Result = 0);
914 Set_Priority (T, Priority);
921 procedure Finalize_TCB (T : Task_ID) is
922 Result : Interfaces.C.int;
925 procedure Free is new
926 Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID);
929 if not Single_Lock then
930 Result := pthread_mutex_destroy (T.Common.LL.L'Access);
931 pragma Assert (Result = 0);
934 Result := pthread_cond_destroy (T.Common.LL.CV'Access);
935 pragma Assert (Result = 0);
937 if T.Known_Tasks_Index /= -1 then
938 Known_Tasks (T.Known_Tasks_Index) := null;
948 procedure Exit_Task is
950 pthread_exit (System.Null_Address);
957 procedure Abort_Task (T : Task_ID) is
958 Result : Interfaces.C.int;
961 Result := pthread_kill (T.Common.LL.Thread,
962 Signal (System.Interrupt_Management.Abort_Task_Interrupt));
963 pragma Assert (Result = 0);
970 -- Dummy versions. The only currently working versions is for solaris
973 function Check_Exit (Self_ID : ST.Task_ID) return Boolean is
982 function Check_No_Locks (Self_ID : ST.Task_ID) return Boolean is
987 ----------------------
988 -- Environment_Task --
989 ----------------------
991 function Environment_Task return Task_ID is
993 return Environment_Task_ID;
994 end Environment_Task;
1000 function Suspend_Task
1002 Thread_Self : Thread_Id) return Boolean is
1004 if T.Common.LL.Thread /= Thread_Self then
1005 return pthread_kill (T.Common.LL.Thread, SIGSTOP) = 0;
1015 function Resume_Task
1017 Thread_Self : Thread_Id) return Boolean is
1019 if T.Common.LL.Thread /= Thread_Self then
1020 return pthread_kill (T.Common.LL.Thread, SIGCONT) = 0;
1030 procedure Initialize (Environment_Task : Task_ID) is
1031 act : aliased struct_sigaction;
1032 old_act : aliased struct_sigaction;
1033 Tmp_Set : aliased sigset_t;
1034 Result : Interfaces.C.int;
1037 Environment_Task_ID := Environment_Task;
1039 Result := pthread_mutexattr_init (Mutex_Attr'Access);
1040 pragma Assert (Result = 0 or else Result = ENOMEM);
1042 Result := pthread_condattr_init (Cond_Attr'Access);
1043 pragma Assert (Result = 0 or else Result = ENOMEM);
1045 Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
1046 -- Initialize the global RTS lock
1048 Specific.Initialize (Environment_Task);
1050 Enter_Task (Environment_Task);
1052 -- Install the abort-signal handler
1055 act.sa_handler := Abort_Handler'Address;
1057 Result := sigemptyset (Tmp_Set'Access);
1058 pragma Assert (Result = 0);
1059 act.sa_mask := Tmp_Set;
1063 (Signal (Interrupt_Management.Abort_Task_Interrupt),
1064 act'Unchecked_Access,
1065 old_act'Unchecked_Access);
1066 pragma Assert (Result = 0);
1071 Result : Interfaces.C.int;
1073 -- Mask Environment task for all signals. The original mask of the
1074 -- Environment task will be recovered by Interrupt_Server task
1075 -- during the elaboration of s-interr.adb.
1077 System.Interrupt_Management.Operations.Set_Interrupt_Mask
1078 (System.Interrupt_Management.Operations.All_Tasks_Mask'Access);
1080 -- Prepare the set of signals that should unblocked in all tasks
1082 Result := sigemptyset (Unblocked_Signal_Mask'Access);
1083 pragma Assert (Result = 0);
1085 for J in Interrupt_Management.Interrupt_ID loop
1086 if System.Interrupt_Management.Keep_Unmasked (J) then
1087 Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
1088 pragma Assert (Result = 0);
1092 end System.Task_Primitives.Operations;