1 ------------------------------------------------------------------------------
3 -- GNAT 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-2007, 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 Solaris (native) 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.
43 with System
.Tasking
.Debug
;
44 -- used for Known_Tasks
46 with System
.Interrupt_Management
;
47 -- used for Keep_Unmasked
48 -- Abort_Task_Interrupt
51 with System
.OS_Primitives
;
52 -- used for Delay_Modes
54 pragma Warnings
(Off
);
56 -- used for String_Access, Getenv
64 with System
.Task_Info
;
65 -- to initialize Task_Info for a C thread, in function Self
67 with System
.Soft_Links
;
68 -- used for Defer/Undefer_Abort
70 -- We use System.Soft_Links instead of System.Tasking.Initialization
71 -- because the later is a higher level package that we shouldn't depend on.
72 -- For example when using the restricted run time, it is replaced by
73 -- System.Tasking.Restricted.Stages.
75 with Ada
.Unchecked_Deallocation
;
77 package body System
.Task_Primitives
.Operations
is
79 package SSL
renames System
.Soft_Links
;
81 use System
.Tasking
.Debug
;
84 use System
.OS_Interface
;
85 use System
.Parameters
;
86 use System
.OS_Primitives
;
92 -- The following are logically constants, but need to be initialized
95 Environment_Task_Id
: Task_Id
;
96 -- A variable to hold Task_Id for the environment task.
97 -- If we use this variable to get the Task_Id, we need the following
98 -- ATCB_Key only for non-Ada threads.
100 Unblocked_Signal_Mask
: aliased sigset_t
;
101 -- The set of signals that should unblocked in all tasks
103 ATCB_Key
: aliased thread_key_t
;
104 -- Key used to find the Ada Task_Id associated with a thread,
105 -- at least for C threads unknown to the Ada run-time system.
107 Single_RTS_Lock
: aliased RTS_Lock
;
108 -- This is a lock to allow only one thread of control in the RTS at
109 -- a time; it is used to execute in mutual exclusion from all other tasks.
110 -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List
112 Next_Serial_Number
: Task_Serial_Number
:= 100;
113 -- We start at 100, to reserve some special values for
114 -- using in error checking.
115 -- The following are internal configuration constants needed.
117 ----------------------
118 -- Priority Support --
119 ----------------------
121 Priority_Ceiling_Emulation
: constant Boolean := True;
122 -- controls whether we emulate priority ceiling locking
124 -- To get a scheduling close to annex D requirements, we use the real-time
125 -- class provided for LWP's and map each task/thread to a specific and
126 -- unique LWP (there is 1 thread per LWP, and 1 LWP per thread).
128 -- The real time class can only be set when the process has root
129 -- priviledges, so in the other cases, we use the normal thread scheduling
130 -- and priority handling.
132 Using_Real_Time_Class
: Boolean := False;
133 -- indicates wether the real time class is being used (i.e the process
134 -- has root priviledges).
136 Prio_Param
: aliased struct_pcparms
;
137 -- Hold priority info (Real_Time) initialized during the package
140 -----------------------------------
141 -- External Configuration Values --
142 -----------------------------------
144 Time_Slice_Val
: Integer;
145 pragma Import
(C
, Time_Slice_Val
, "__gl_time_slice_val");
147 Locking_Policy
: Character;
148 pragma Import
(C
, Locking_Policy
, "__gl_locking_policy");
150 Dispatching_Policy
: Character;
151 pragma Import
(C
, Dispatching_Policy
, "__gl_task_dispatching_policy");
153 Foreign_Task_Elaborated
: aliased Boolean := True;
154 -- Used to identified fake tasks (i.e., non-Ada Threads)
156 -----------------------
157 -- Local Subprograms --
158 -----------------------
160 function sysconf
(name
: System
.OS_Interface
.int
) return processorid_t
;
161 pragma Import
(C
, sysconf
, "sysconf");
163 SC_NPROCESSORS_CONF
: constant System
.OS_Interface
.int
:= 14;
166 (name
: System
.OS_Interface
.int
:= SC_NPROCESSORS_CONF
)
167 return processorid_t
renames sysconf
;
169 procedure Abort_Handler
171 Code
: not null access siginfo_t
;
172 Context
: not null access ucontext_t
);
173 -- Target-dependent binding of inter-thread Abort signal to
174 -- the raising of the Abort_Signal exception.
175 -- See also comments in 7staprop.adb
181 function Check_Initialize_Lock
183 Level
: Lock_Level
) return Boolean;
184 pragma Inline
(Check_Initialize_Lock
);
186 function Check_Lock
(L
: Lock_Ptr
) return Boolean;
187 pragma Inline
(Check_Lock
);
189 function Record_Lock
(L
: Lock_Ptr
) return Boolean;
190 pragma Inline
(Record_Lock
);
192 function Check_Sleep
(Reason
: Task_States
) return Boolean;
193 pragma Inline
(Check_Sleep
);
195 function Record_Wakeup
197 Reason
: Task_States
) return Boolean;
198 pragma Inline
(Record_Wakeup
);
200 function Check_Wakeup
202 Reason
: Task_States
) return Boolean;
203 pragma Inline
(Check_Wakeup
);
205 function Check_Unlock
(L
: Lock_Ptr
) return Boolean;
206 pragma Inline
(Check_Unlock
);
208 function Check_Finalize_Lock
(L
: Lock_Ptr
) return Boolean;
209 pragma Inline
(Check_Finalize_Lock
);
217 procedure Initialize
(Environment_Task
: Task_Id
);
218 pragma Inline
(Initialize
);
219 -- Initialize various data needed by this package
221 function Is_Valid_Task
return Boolean;
222 pragma Inline
(Is_Valid_Task
);
223 -- Does executing thread have a TCB?
225 procedure Set
(Self_Id
: Task_Id
);
227 -- Set the self id for the current task
229 function Self
return Task_Id
;
230 pragma Inline
(Self
);
231 -- Return a pointer to the Ada Task Control Block of the calling task
235 package body Specific
is separate;
236 -- The body of this package is target specific
238 ---------------------------------
239 -- Support for foreign threads --
240 ---------------------------------
242 function Register_Foreign_Thread
(Thread
: Thread_Id
) return Task_Id
;
243 -- Allocate and Initialize a new ATCB for the current Thread
245 function Register_Foreign_Thread
246 (Thread
: Thread_Id
) return Task_Id
is separate;
252 Check_Count
: Integer := 0;
253 Lock_Count
: Integer := 0;
254 Unlock_Count
: Integer := 0;
260 procedure Abort_Handler
262 Code
: not null access siginfo_t
;
263 Context
: not null access ucontext_t
)
265 pragma Unreferenced
(Sig
);
266 pragma Unreferenced
(Code
);
267 pragma Unreferenced
(Context
);
269 Self_ID
: constant Task_Id
:= Self
;
270 Old_Set
: aliased sigset_t
;
272 Result
: Interfaces
.C
.int
;
275 -- It is not safe to raise an exception when using ZCX and the GCC
276 -- exception handling mechanism.
278 if ZCX_By_Default
and then GCC_ZCX_Support
then
282 if Self_ID
.Deferral_Level
= 0
283 and then Self_ID
.Pending_ATC_Level
< Self_ID
.ATC_Nesting_Level
284 and then not Self_ID
.Aborting
286 Self_ID
.Aborting
:= True;
288 -- Make sure signals used for RTS internal purpose are unmasked
293 Unblocked_Signal_Mask
'Unchecked_Access,
294 Old_Set
'Unchecked_Access);
295 pragma Assert
(Result
= 0);
297 raise Standard
'Abort_Signal;
305 -- The underlying thread system sets a guard page at the
306 -- bottom of a thread stack, so nothing is needed.
308 procedure Stack_Guard
(T
: ST
.Task_Id
; On
: Boolean) is
309 pragma Unreferenced
(T
);
310 pragma Unreferenced
(On
);
319 function Get_Thread_Id
(T
: ST
.Task_Id
) return OSI
.Thread_Id
is
321 return T
.Common
.LL
.Thread
;
328 procedure Initialize
(Environment_Task
: ST
.Task_Id
) is
329 act
: aliased struct_sigaction
;
330 old_act
: aliased struct_sigaction
;
331 Tmp_Set
: aliased sigset_t
;
332 Result
: Interfaces
.C
.int
;
334 procedure Configure_Processors
;
335 -- Processors configuration
336 -- The user can specify a processor which the program should run
337 -- on to emulate a single-processor system. This can be easily
338 -- done by setting environment variable GNAT_PROCESSOR to one of
341 -- -2 : use the default configuration (run the program on all
342 -- available processors) - this is the same as having
343 -- GNAT_PROCESSOR unset
344 -- -1 : let the RTS choose one processor and run the program on
346 -- 0 .. Last_Proc : run the program on the specified processor
348 -- Last_Proc is equal to the value of the system variable
349 -- _SC_NPROCESSORS_CONF, minus one.
351 procedure Configure_Processors
is
352 Proc_Acc
: constant System
.OS_Lib
.String_Access
:=
353 System
.OS_Lib
.Getenv
("GNAT_PROCESSOR");
354 Proc
: aliased processorid_t
; -- User processor #
355 Last_Proc
: processorid_t
; -- Last processor #
358 if Proc_Acc
.all'Length /= 0 then
360 -- Environment variable is defined
362 Last_Proc
:= Num_Procs
- 1;
364 if Last_Proc
/= -1 then
365 Proc
:= processorid_t
'Value (Proc_Acc
.all);
367 if Proc
<= -2 or else Proc
> Last_Proc
then
369 -- Use the default configuration
375 -- Choose a processor
378 while Proc
< Last_Proc
loop
380 Result
:= p_online
(Proc
, PR_STATUS
);
381 exit when Result
= PR_ONLINE
;
384 pragma Assert
(Result
= PR_ONLINE
);
385 Result
:= processor_bind
(P_PID
, P_MYID
, Proc
, null);
386 pragma Assert
(Result
= 0);
389 -- Use user processor
391 Result
:= processor_bind
(P_PID
, P_MYID
, Proc
, null);
392 pragma Assert
(Result
= 0);
398 when Constraint_Error
=>
400 -- Illegal environment variable GNAT_PROCESSOR - ignored
403 end Configure_Processors
;
406 (Int
: System
.Interrupt_Management
.Interrupt_ID
) return Character;
407 pragma Import
(C
, State
, "__gnat_get_interrupt_state");
408 -- Get interrupt state. Defined in a-init.c
409 -- The input argument is the interrupt number,
410 -- and the result is one of the following:
412 Default
: constant Character := 's';
413 -- 'n' this interrupt not set by any Interrupt_State pragma
414 -- 'u' Interrupt_State pragma set state to User
415 -- 'r' Interrupt_State pragma set state to Runtime
416 -- 's' Interrupt_State pragma set state to System (use "default"
419 -- Start of processing for Initialize
422 Environment_Task_Id
:= Environment_Task
;
424 Interrupt_Management
.Initialize
;
426 -- Prepare the set of signals that should unblocked in all tasks
428 Result
:= sigemptyset
(Unblocked_Signal_Mask
'Access);
429 pragma Assert
(Result
= 0);
431 for J
in Interrupt_Management
.Interrupt_ID
loop
432 if System
.Interrupt_Management
.Keep_Unmasked
(J
) then
433 Result
:= sigaddset
(Unblocked_Signal_Mask
'Access, Signal
(J
));
434 pragma Assert
(Result
= 0);
438 if Dispatching_Policy
= 'F' then
440 Result
: Interfaces
.C
.long
;
441 Class_Info
: aliased struct_pcinfo
;
442 Secs
, Nsecs
: Interfaces
.C
.long
;
445 -- If a pragma Time_Slice is specified, takes the value in account
447 if Time_Slice_Val
> 0 then
449 -- Convert Time_Slice_Val (microseconds) to seconds/nanosecs
451 Secs
:= Interfaces
.C
.long
(Time_Slice_Val
/ 1_000_000
);
453 Interfaces
.C
.long
((Time_Slice_Val
rem 1_000_000
) * 1_000
);
455 -- Otherwise, default to no time slicing (i.e run until blocked)
462 -- Get the real time class id
464 Class_Info
.pc_clname
(1) := 'R';
465 Class_Info
.pc_clname
(2) := 'T';
466 Class_Info
.pc_clname
(3) := ASCII
.NUL
;
468 Result
:= priocntl
(PC_VERSION
, P_LWPID
, P_MYID
, PC_GETCID
,
471 -- Request the real time class
473 Prio_Param
.pc_cid
:= Class_Info
.pc_cid
;
474 Prio_Param
.rt_pri
:= pri_t
(Class_Info
.rt_maxpri
);
475 Prio_Param
.rt_tqsecs
:= Secs
;
476 Prio_Param
.rt_tqnsecs
:= Nsecs
;
480 (PC_VERSION
, P_LWPID
, P_MYID
, PC_SETPARMS
, Prio_Param
'Address);
482 Using_Real_Time_Class
:= Result
/= -1;
486 Specific
.Initialize
(Environment_Task
);
488 -- The following is done in Enter_Task, but this is too late for the
489 -- Environment Task, since we need to call Self in Check_Locks when
490 -- the run time is compiled with assertions on.
492 Specific
.Set
(Environment_Task
);
494 -- Initialize the lock used to synchronize chain of all ATCBs
496 Initialize_Lock
(Single_RTS_Lock
'Access, RTS_Lock_Level
);
498 Enter_Task
(Environment_Task
);
500 -- Install the abort-signal handler
503 (System
.Interrupt_Management
.Abort_Task_Interrupt
) /= Default
505 -- Set sa_flags to SA_NODEFER so that during the handler execution
506 -- we do not change the Signal_Mask to be masked for the Abort_Signal
507 -- This is a temporary fix to the problem that the Signal_Mask is
508 -- not restored after the exception (longjmp) from the handler.
509 -- The right fix should be made in sigsetjmp so that we save
510 -- the Signal_Set and restore it after a longjmp.
511 -- In that case, this field should be changed back to 0. ???
515 act
.sa_handler
:= Abort_Handler
'Address;
516 Result
:= sigemptyset
(Tmp_Set
'Access);
517 pragma Assert
(Result
= 0);
518 act
.sa_mask
:= Tmp_Set
;
522 (Signal
(System
.Interrupt_Management
.Abort_Task_Interrupt
),
523 act
'Unchecked_Access,
524 old_act
'Unchecked_Access);
525 pragma Assert
(Result
= 0);
528 Configure_Processors
;
531 ---------------------
532 -- Initialize_Lock --
533 ---------------------
535 -- Note: mutexes and cond_variables needed per-task basis are initialized
536 -- in Initialize_TCB and the Storage_Error is handled. Other mutexes (such
537 -- as RTS_Lock, Memory_Lock...) used in RTS is initialized before any
538 -- status change of RTS. Therefore rasing Storage_Error in the following
539 -- routines should be able to be handled safely.
541 procedure Initialize_Lock
542 (Prio
: System
.Any_Priority
;
543 L
: not null access Lock
)
545 Result
: Interfaces
.C
.int
;
548 pragma Assert
(Check_Initialize_Lock
(Lock_Ptr
(L
), PO_Level
));
550 if Priority_Ceiling_Emulation
then
554 Result
:= mutex_init
(L
.L
'Access, USYNC_THREAD
, System
.Null_Address
);
555 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
557 if Result
= ENOMEM
then
558 raise Storage_Error
with "Failed to allocate a lock";
562 procedure Initialize_Lock
563 (L
: not null access RTS_Lock
;
566 Result
: Interfaces
.C
.int
;
570 (Check_Initialize_Lock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
)), Level
));
571 Result
:= mutex_init
(L
.L
'Access, USYNC_THREAD
, System
.Null_Address
);
572 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
574 if Result
= ENOMEM
then
575 raise Storage_Error
with "Failed to allocate a lock";
583 procedure Finalize_Lock
(L
: not null access Lock
) is
584 Result
: Interfaces
.C
.int
;
586 pragma Assert
(Check_Finalize_Lock
(Lock_Ptr
(L
)));
587 Result
:= mutex_destroy
(L
.L
'Access);
588 pragma Assert
(Result
= 0);
591 procedure Finalize_Lock
(L
: not null access RTS_Lock
) is
592 Result
: Interfaces
.C
.int
;
594 pragma Assert
(Check_Finalize_Lock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
))));
595 Result
:= mutex_destroy
(L
.L
'Access);
596 pragma Assert
(Result
= 0);
604 (L
: not null access Lock
;
605 Ceiling_Violation
: out Boolean)
607 Result
: Interfaces
.C
.int
;
610 pragma Assert
(Check_Lock
(Lock_Ptr
(L
)));
612 if Priority_Ceiling_Emulation
and then Locking_Policy
= 'C' then
614 Self_Id
: constant Task_Id
:= Self
;
615 Saved_Priority
: System
.Any_Priority
;
618 if Self_Id
.Common
.LL
.Active_Priority
> L
.Ceiling
then
619 Ceiling_Violation
:= True;
623 Saved_Priority
:= Self_Id
.Common
.LL
.Active_Priority
;
625 if Self_Id
.Common
.LL
.Active_Priority
< L
.Ceiling
then
626 Set_Priority
(Self_Id
, L
.Ceiling
);
629 Result
:= mutex_lock
(L
.L
'Access);
630 pragma Assert
(Result
= 0);
631 Ceiling_Violation
:= False;
633 L
.Saved_Priority
:= Saved_Priority
;
637 Result
:= mutex_lock
(L
.L
'Access);
638 pragma Assert
(Result
= 0);
639 Ceiling_Violation
:= False;
642 pragma Assert
(Record_Lock
(Lock_Ptr
(L
)));
646 (L
: not null access RTS_Lock
;
647 Global_Lock
: Boolean := False)
649 Result
: Interfaces
.C
.int
;
651 if not Single_Lock
or else Global_Lock
then
652 pragma Assert
(Check_Lock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
))));
653 Result
:= mutex_lock
(L
.L
'Access);
654 pragma Assert
(Result
= 0);
655 pragma Assert
(Record_Lock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
))));
659 procedure Write_Lock
(T
: Task_Id
) is
660 Result
: Interfaces
.C
.int
;
662 if not Single_Lock
then
663 pragma Assert
(Check_Lock
(To_Lock_Ptr
(T
.Common
.LL
.L
'Access)));
664 Result
:= mutex_lock
(T
.Common
.LL
.L
.L
'Access);
665 pragma Assert
(Result
= 0);
666 pragma Assert
(Record_Lock
(To_Lock_Ptr
(T
.Common
.LL
.L
'Access)));
675 (L
: not null access Lock
;
676 Ceiling_Violation
: out Boolean) is
678 Write_Lock
(L
, Ceiling_Violation
);
685 procedure Unlock
(L
: not null access Lock
) is
686 Result
: Interfaces
.C
.int
;
689 pragma Assert
(Check_Unlock
(Lock_Ptr
(L
)));
691 if Priority_Ceiling_Emulation
and then Locking_Policy
= 'C' then
693 Self_Id
: constant Task_Id
:= Self
;
696 Result
:= mutex_unlock
(L
.L
'Access);
697 pragma Assert
(Result
= 0);
699 if Self_Id
.Common
.LL
.Active_Priority
> L
.Saved_Priority
then
700 Set_Priority
(Self_Id
, L
.Saved_Priority
);
704 Result
:= mutex_unlock
(L
.L
'Access);
705 pragma Assert
(Result
= 0);
710 (L
: not null access RTS_Lock
;
711 Global_Lock
: Boolean := False)
713 Result
: Interfaces
.C
.int
;
715 if not Single_Lock
or else Global_Lock
then
716 pragma Assert
(Check_Unlock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
))));
717 Result
:= mutex_unlock
(L
.L
'Access);
718 pragma Assert
(Result
= 0);
722 procedure Unlock
(T
: Task_Id
) is
723 Result
: Interfaces
.C
.int
;
725 if not Single_Lock
then
726 pragma Assert
(Check_Unlock
(To_Lock_Ptr
(T
.Common
.LL
.L
'Access)));
727 Result
:= mutex_unlock
(T
.Common
.LL
.L
.L
'Access);
728 pragma Assert
(Result
= 0);
736 -- Dynamic priority ceilings are not supported by the underlying system
738 procedure Set_Ceiling
739 (L
: not null access Lock
;
740 Prio
: System
.Any_Priority
)
742 pragma Unreferenced
(L
, Prio
);
747 -- For the time delay implementation, we need to make sure we
748 -- achieve following criteria:
750 -- 1) We have to delay at least for the amount requested.
751 -- 2) We have to give up CPU even though the actual delay does not
752 -- result in blocking.
753 -- 3) Except for restricted run-time systems that do not support
754 -- ATC or task abort, the delay must be interrupted by the
755 -- abort_task operation.
756 -- 4) The implementation has to be efficient so that the delay overhead
757 -- is relatively cheap.
758 -- (1)-(3) are Ada requirements. Even though (2) is an Annex-D
759 -- requirement we still want to provide the effect in all cases.
760 -- The reason is that users may want to use short delays to implement
761 -- their own scheduling effect in the absence of language provided
762 -- scheduling policies.
764 ---------------------
765 -- Monotonic_Clock --
766 ---------------------
768 function Monotonic_Clock
return Duration is
769 TS
: aliased timespec
;
770 Result
: Interfaces
.C
.int
;
772 Result
:= clock_gettime
(CLOCK_REALTIME
, TS
'Unchecked_Access);
773 pragma Assert
(Result
= 0);
774 return To_Duration
(TS
);
781 function RT_Resolution
return Duration is
790 procedure Yield
(Do_Yield
: Boolean := True) is
793 System
.OS_Interface
.thr_yield
;
801 function Self
return Task_Id
renames Specific
.Self
;
807 procedure Set_Priority
809 Prio
: System
.Any_Priority
;
810 Loss_Of_Inheritance
: Boolean := False)
812 pragma Unreferenced
(Loss_Of_Inheritance
);
814 Result
: Interfaces
.C
.int
;
815 pragma Unreferenced
(Result
);
817 Param
: aliased struct_pcparms
;
822 T
.Common
.Current_Priority
:= Prio
;
824 if Priority_Ceiling_Emulation
then
825 T
.Common
.LL
.Active_Priority
:= Prio
;
828 if Using_Real_Time_Class
then
829 Param
.pc_cid
:= Prio_Param
.pc_cid
;
830 Param
.rt_pri
:= pri_t
(Prio
);
831 Param
.rt_tqsecs
:= Prio_Param
.rt_tqsecs
;
832 Param
.rt_tqnsecs
:= Prio_Param
.rt_tqnsecs
;
834 Result
:= Interfaces
.C
.int
(
835 priocntl
(PC_VERSION
, P_LWPID
, T
.Common
.LL
.LWP
, PC_SETPARMS
,
839 if T
.Common
.Task_Info
/= null
840 and then not T
.Common
.Task_Info
.Bound_To_LWP
842 -- The task is not bound to a LWP, so use thr_setprio
845 thr_setprio
(T
.Common
.LL
.Thread
, Interfaces
.C
.int
(Prio
));
848 -- The task is bound to a LWP, use priocntl
860 function Get_Priority
(T
: Task_Id
) return System
.Any_Priority
is
862 return T
.Common
.Current_Priority
;
869 procedure Enter_Task
(Self_ID
: Task_Id
) is
870 Result
: Interfaces
.C
.int
;
871 Proc
: processorid_t
; -- User processor #
872 Last_Proc
: processorid_t
; -- Last processor #
874 use System
.Task_Info
;
876 Self_ID
.Common
.LL
.Thread
:= thr_self
;
878 Self_ID
.Common
.LL
.LWP
:= lwp_self
;
880 if Self_ID
.Common
.Task_Info
/= null then
881 if Self_ID
.Common
.Task_Info
.New_LWP
882 and then Self_ID
.Common
.Task_Info
.CPU
/= CPU_UNCHANGED
884 Last_Proc
:= Num_Procs
- 1;
886 if Self_ID
.Common
.Task_Info
.CPU
= ANY_CPU
then
889 while Proc
< Last_Proc
loop
890 Result
:= p_online
(Proc
, PR_STATUS
);
891 exit when Result
= PR_ONLINE
;
895 Result
:= processor_bind
(P_LWPID
, P_MYID
, Proc
, null);
896 pragma Assert
(Result
= 0);
899 -- Use specified processor
901 if Self_ID
.Common
.Task_Info
.CPU
< 0
902 or else Self_ID
.Common
.Task_Info
.CPU
> Last_Proc
904 raise Invalid_CPU_Number
;
909 (P_LWPID
, P_MYID
, Self_ID
.Common
.Task_Info
.CPU
, null);
910 pragma Assert
(Result
= 0);
915 Specific
.Set
(Self_ID
);
917 -- We need the above code even if we do direct fetch of Task_Id in Self
918 -- for the main task on Sun, x86 Solaris and for gcc 2.7.2.
922 for J
in Known_Tasks
'Range loop
923 if Known_Tasks
(J
) = null then
924 Known_Tasks
(J
) := Self_ID
;
925 Self_ID
.Known_Tasks_Index
:= J
;
937 function New_ATCB
(Entry_Num
: Task_Entry_Index
) return Task_Id
is
939 return new Ada_Task_Control_Block
(Entry_Num
);
946 function Is_Valid_Task
return Boolean renames Specific
.Is_Valid_Task
;
948 -----------------------------
949 -- Register_Foreign_Thread --
950 -----------------------------
952 function Register_Foreign_Thread
return Task_Id
is
954 if Is_Valid_Task
then
957 return Register_Foreign_Thread
(thr_self
);
959 end Register_Foreign_Thread
;
965 procedure Initialize_TCB
(Self_ID
: Task_Id
; Succeeded
: out Boolean) is
966 Result
: Interfaces
.C
.int
:= 0;
969 -- Give the task a unique serial number
971 Self_ID
.Serial_Number
:= Next_Serial_Number
;
972 Next_Serial_Number
:= Next_Serial_Number
+ 1;
973 pragma Assert
(Next_Serial_Number
/= 0);
975 Self_ID
.Common
.LL
.Thread
:= To_thread_t
(-1);
977 if not Single_Lock
then
980 (Self_ID
.Common
.LL
.L
.L
'Access, USYNC_THREAD
, System
.Null_Address
);
981 Self_ID
.Common
.LL
.L
.Level
:=
982 Private_Task_Serial_Number
(Self_ID
.Serial_Number
);
983 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
987 Result
:= cond_init
(Self_ID
.Common
.LL
.CV
'Access, USYNC_THREAD
, 0);
988 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
994 if not Single_Lock
then
995 Result
:= mutex_destroy
(Self_ID
.Common
.LL
.L
.L
'Access);
996 pragma Assert
(Result
= 0);
1007 procedure Create_Task
1009 Wrapper
: System
.Address
;
1010 Stack_Size
: System
.Parameters
.Size_Type
;
1011 Priority
: System
.Any_Priority
;
1012 Succeeded
: out Boolean)
1014 pragma Unreferenced
(Priority
);
1016 Result
: Interfaces
.C
.int
;
1017 Adjusted_Stack_Size
: Interfaces
.C
.size_t
;
1018 Opts
: Interfaces
.C
.int
:= THR_DETACHED
;
1020 Page_Size
: constant System
.Parameters
.Size_Type
:= 4096;
1021 -- This constant is for reserving extra space at the
1022 -- end of the stack, which can be used by the stack
1023 -- checking as guard page. The idea is that we need
1024 -- to have at least Stack_Size bytes available for
1027 use System
.Task_Info
;
1030 Adjusted_Stack_Size
:= Interfaces
.C
.size_t
(Stack_Size
+ Page_Size
);
1032 -- Since the initial signal mask of a thread is inherited from the
1033 -- creator, and the Environment task has all its signals masked, we
1034 -- do not need to manipulate caller's signal mask at this point.
1035 -- All tasks in RTS will have All_Tasks_Mask initially.
1037 if T
.Common
.Task_Info
/= null then
1038 if T
.Common
.Task_Info
.New_LWP
then
1039 Opts
:= Opts
+ THR_NEW_LWP
;
1042 if T
.Common
.Task_Info
.Bound_To_LWP
then
1043 Opts
:= Opts
+ THR_BOUND
;
1047 Opts
:= THR_DETACHED
+ THR_BOUND
;
1052 (System
.Null_Address
,
1053 Adjusted_Stack_Size
,
1054 Thread_Body_Access
(Wrapper
),
1057 T
.Common
.LL
.Thread
'Access);
1059 Succeeded
:= Result
= 0;
1062 or else Result
= ENOMEM
1063 or else Result
= EAGAIN
);
1070 procedure Finalize_TCB
(T
: Task_Id
) is
1071 Result
: Interfaces
.C
.int
;
1073 Is_Self
: constant Boolean := T
= Self
;
1075 procedure Free
is new
1076 Ada
.Unchecked_Deallocation
(Ada_Task_Control_Block
, Task_Id
);
1079 T
.Common
.LL
.Thread
:= To_thread_t
(0);
1081 if not Single_Lock
then
1082 Result
:= mutex_destroy
(T
.Common
.LL
.L
.L
'Access);
1083 pragma Assert
(Result
= 0);
1086 Result
:= cond_destroy
(T
.Common
.LL
.CV
'Access);
1087 pragma Assert
(Result
= 0);
1089 if T
.Known_Tasks_Index
/= -1 then
1090 Known_Tasks
(T
.Known_Tasks_Index
) := null;
1096 Specific
.Set
(null);
1104 -- This procedure must be called with abort deferred. It can no longer
1105 -- call Self or access the current task's ATCB, since the ATCB has been
1108 procedure Exit_Task
is
1110 Specific
.Set
(null);
1117 procedure Abort_Task
(T
: Task_Id
) is
1118 Result
: Interfaces
.C
.int
;
1120 pragma Assert
(T
/= Self
);
1123 (T
.Common
.LL
.Thread
,
1124 Signal
(System
.Interrupt_Management
.Abort_Task_Interrupt
));
1125 pragma Assert
(Result
= 0);
1134 Reason
: Task_States
)
1136 Result
: Interfaces
.C
.int
;
1139 pragma Assert
(Check_Sleep
(Reason
));
1144 (Self_ID
.Common
.LL
.CV
'Access, Single_RTS_Lock
.L
'Access);
1148 (Self_ID
.Common
.LL
.CV
'Access, Self_ID
.Common
.LL
.L
.L
'Access);
1152 (Record_Wakeup
(To_Lock_Ptr
(Self_ID
.Common
.LL
.L
'Access), Reason
));
1153 pragma Assert
(Result
= 0 or else Result
= EINTR
);
1156 -- Note that we are relying heaviliy here on GNAT represting Calendar.Time,
1157 -- System.Real_Time.Time, Duration, System.Real_Time.Time_Span in the same
1158 -- way, i.e., as a 64-bit count of nanoseconds.
1160 -- This allows us to always pass the timeout value as a Duration
1163 -- We are taking liberties here with the semantics of the delays. That is,
1164 -- we make no distinction between delays on the Calendar clock and delays
1165 -- on the Real_Time clock. That is technically incorrect, if the Calendar
1166 -- clock happens to be reset or adjusted. To solve this defect will require
1167 -- modification to the compiler interface, so that it can pass through more
1168 -- information, to tell us here which clock to use!
1170 -- cond_timedwait will return if any of the following happens:
1171 -- 1) some other task did cond_signal on this condition variable
1172 -- In this case, the return value is 0
1173 -- 2) the call just returned, for no good reason
1174 -- This is called a "spurious wakeup".
1175 -- In this case, the return value may also be 0.
1176 -- 3) the time delay expires
1177 -- In this case, the return value is ETIME
1178 -- 4) this task received a signal, which was handled by some
1179 -- handler procedure, and now the thread is resuming execution
1180 -- UNIX calls this an "interrupted" system call.
1181 -- In this case, the return value is EINTR
1183 -- If the cond_timedwait returns 0 or EINTR, it is still possible that the
1184 -- time has actually expired, and by chance a signal or cond_signal
1185 -- occurred at around the same time.
1187 -- We have also observed that on some OS's the value ETIME will be
1188 -- returned, but the clock will show that the full delay has not yet
1191 -- For these reasons, we need to check the clock after return from
1192 -- cond_timedwait. If the time has expired, we will set Timedout = True.
1194 -- This check might be omitted for systems on which the cond_timedwait()
1195 -- never returns early or wakes up spuriously.
1197 -- Annex D requires that completion of a delay cause the task to go to the
1198 -- end of its priority queue, regardless of whether the task actually was
1199 -- suspended by the delay. Since cond_timedwait does not do this on
1200 -- Solaris, we add a call to thr_yield at the end. We might do this at the
1201 -- beginning, instead, but then the round-robin effect would not be the
1202 -- same; the delayed task would be ahead of other tasks of the same
1203 -- priority that awoke while it was sleeping.
1205 -- For Timed_Sleep, we are expecting possible cond_signals to indicate
1206 -- other events (e.g., completion of a RV or completion of the abortable
1207 -- part of an async. select), we want to always return if interrupted. The
1208 -- caller will be responsible for checking the task state to see whether
1209 -- the wakeup was spurious, and to go back to sleep again in that case. We
1210 -- don't need to check for pending abort or priority change on the way in
1211 -- our out; that is the caller's responsibility.
1213 -- For Timed_Delay, we are not expecting any cond_signals or other
1214 -- interruptions, except for priority changes and aborts. Therefore, we
1215 -- don't want to return unless the delay has actually expired, or the call
1216 -- has been aborted. In this case, since we want to implement the entire
1217 -- delay statement semantics, we do need to check for pending abort and
1218 -- priority changes. We can quietly handle priority changes inside the
1219 -- procedure, since there is no entry-queue reordering involved.
1225 procedure Timed_Sleep
1228 Mode
: ST
.Delay_Modes
;
1229 Reason
: System
.Tasking
.Task_States
;
1230 Timedout
: out Boolean;
1231 Yielded
: out Boolean)
1233 Base_Time
: constant Duration := Monotonic_Clock
;
1234 Check_Time
: Duration := Base_Time
;
1235 Abs_Time
: Duration;
1236 Request
: aliased timespec
;
1237 Result
: Interfaces
.C
.int
;
1240 pragma Assert
(Check_Sleep
(Reason
));
1244 if Mode
= Relative
then
1245 Abs_Time
:= Duration'Min (Time
, Max_Sensible_Delay
) + Check_Time
;
1247 Abs_Time
:= Duration'Min (Check_Time
+ Max_Sensible_Delay
, Time
);
1250 if Abs_Time
> Check_Time
then
1251 Request
:= To_Timespec
(Abs_Time
);
1254 exit when Self_ID
.Pending_ATC_Level
< Self_ID
.ATC_Nesting_Level
;
1259 (Self_ID
.Common
.LL
.CV
'Access,
1260 Single_RTS_Lock
.L
'Access, Request
'Access);
1264 (Self_ID
.Common
.LL
.CV
'Access,
1265 Self_ID
.Common
.LL
.L
.L
'Access, Request
'Access);
1270 Check_Time
:= Monotonic_Clock
;
1271 exit when Abs_Time
<= Check_Time
or else Check_Time
< Base_Time
;
1273 if Result
= 0 or Result
= EINTR
then
1275 -- Somebody may have called Wakeup for us
1281 pragma Assert
(Result
= ETIME
);
1286 (Record_Wakeup
(To_Lock_Ptr
(Self_ID
.Common
.LL
.L
'Access), Reason
));
1293 procedure Timed_Delay
1296 Mode
: ST
.Delay_Modes
)
1298 Base_Time
: constant Duration := Monotonic_Clock
;
1299 Check_Time
: Duration := Base_Time
;
1300 Abs_Time
: Duration;
1301 Request
: aliased timespec
;
1302 Result
: Interfaces
.C
.int
;
1303 Yielded
: Boolean := False;
1310 Write_Lock
(Self_ID
);
1312 if Mode
= Relative
then
1313 Abs_Time
:= Time
+ Check_Time
;
1315 Abs_Time
:= Duration'Min (Check_Time
+ Max_Sensible_Delay
, Time
);
1318 if Abs_Time
> Check_Time
then
1319 Request
:= To_Timespec
(Abs_Time
);
1320 Self_ID
.Common
.State
:= Delay_Sleep
;
1322 pragma Assert
(Check_Sleep
(Delay_Sleep
));
1325 exit when Self_ID
.Pending_ATC_Level
< Self_ID
.ATC_Nesting_Level
;
1330 (Self_ID
.Common
.LL
.CV
'Access,
1331 Single_RTS_Lock
.L
'Access,
1336 (Self_ID
.Common
.LL
.CV
'Access,
1337 Self_ID
.Common
.LL
.L
.L
'Access,
1343 Check_Time
:= Monotonic_Clock
;
1344 exit when Abs_Time
<= Check_Time
or else Check_Time
< Base_Time
;
1348 Result
= ETIME
or else
1354 (To_Lock_Ptr
(Self_ID
.Common
.LL
.L
'Access), Delay_Sleep
));
1356 Self_ID
.Common
.State
:= Runnable
;
1376 Reason
: Task_States
)
1378 Result
: Interfaces
.C
.int
;
1380 pragma Assert
(Check_Wakeup
(T
, Reason
));
1381 Result
:= cond_signal
(T
.Common
.LL
.CV
'Access);
1382 pragma Assert
(Result
= 0);
1385 ---------------------------
1386 -- Check_Initialize_Lock --
1387 ---------------------------
1389 -- The following code is intended to check some of the invariant assertions
1390 -- related to lock usage, on which we depend.
1392 function Check_Initialize_Lock
1394 Level
: Lock_Level
) return Boolean
1396 Self_ID
: constant Task_Id
:= Self
;
1399 -- Check that caller is abort-deferred
1401 if Self_ID
.Deferral_Level
= 0 then
1405 -- Check that the lock is not yet initialized
1407 if L
.Level
/= 0 then
1411 L
.Level
:= Lock_Level
'Pos (Level
) + 1;
1413 end Check_Initialize_Lock
;
1419 function Check_Lock
(L
: Lock_Ptr
) return Boolean is
1420 Self_ID
: constant Task_Id
:= Self
;
1424 -- Check that the argument is not null
1430 -- Check that L is not frozen
1436 -- Check that caller is abort-deferred
1438 if Self_ID
.Deferral_Level
= 0 then
1442 -- Check that caller is not holding this lock already
1444 if L
.Owner
= To_Owner_ID
(To_Address
(Self_ID
)) then
1452 -- Check that TCB lock order rules are satisfied
1454 P
:= Self_ID
.Common
.LL
.Locks
;
1456 if P
.Level
>= L
.Level
1457 and then (P
.Level
> 2 or else L
.Level
> 2)
1470 function Record_Lock
(L
: Lock_Ptr
) return Boolean is
1471 Self_ID
: constant Task_Id
:= Self
;
1475 Lock_Count
:= Lock_Count
+ 1;
1477 -- There should be no owner for this lock at this point
1479 if L
.Owner
/= null then
1485 L
.Owner
:= To_Owner_ID
(To_Address
(Self_ID
));
1491 -- Check that TCB lock order rules are satisfied
1493 P
:= Self_ID
.Common
.LL
.Locks
;
1499 Self_ID
.Common
.LL
.Locking
:= null;
1500 Self_ID
.Common
.LL
.Locks
:= L
;
1508 function Check_Sleep
(Reason
: Task_States
) return Boolean is
1509 pragma Unreferenced
(Reason
);
1511 Self_ID
: constant Task_Id
:= Self
;
1515 -- Check that caller is abort-deferred
1517 if Self_ID
.Deferral_Level
= 0 then
1525 -- Check that caller is holding own lock, on top of list
1527 if Self_ID
.Common
.LL
.Locks
/=
1528 To_Lock_Ptr
(Self_ID
.Common
.LL
.L
'Access)
1533 -- Check that TCB lock order rules are satisfied
1535 if Self_ID
.Common
.LL
.Locks
.Next
/= null then
1539 Self_ID
.Common
.LL
.L
.Owner
:= null;
1540 P
:= Self_ID
.Common
.LL
.Locks
;
1541 Self_ID
.Common
.LL
.Locks
:= Self_ID
.Common
.LL
.Locks
.Next
;
1550 function Record_Wakeup
1552 Reason
: Task_States
) return Boolean
1554 pragma Unreferenced
(Reason
);
1556 Self_ID
: constant Task_Id
:= Self
;
1562 L
.Owner
:= To_Owner_ID
(To_Address
(Self_ID
));
1568 -- Check that TCB lock order rules are satisfied
1570 P
:= Self_ID
.Common
.LL
.Locks
;
1576 Self_ID
.Common
.LL
.Locking
:= null;
1577 Self_ID
.Common
.LL
.Locks
:= L
;
1585 function Check_Wakeup
1587 Reason
: Task_States
) return Boolean
1589 Self_ID
: constant Task_Id
:= Self
;
1592 -- Is caller holding T's lock?
1594 if T
.Common
.LL
.L
.Owner
/= To_Owner_ID
(To_Address
(Self_ID
)) then
1598 -- Are reasons for wakeup and sleep consistent?
1600 if T
.Common
.State
/= Reason
then
1611 function Check_Unlock
(L
: Lock_Ptr
) return Boolean is
1612 Self_ID
: constant Task_Id
:= Self
;
1616 Unlock_Count
:= Unlock_Count
+ 1;
1622 if L
.Buddy
/= null then
1626 -- Magic constant 4???
1629 Check_Count
:= Unlock_Count
;
1632 -- Magic constant 1000???
1634 if Unlock_Count
- Check_Count
> 1000 then
1635 Check_Count
:= Unlock_Count
;
1638 -- Check that caller is abort-deferred
1640 if Self_ID
.Deferral_Level
= 0 then
1644 -- Check that caller is holding this lock, on top of list
1646 if Self_ID
.Common
.LL
.Locks
/= L
then
1650 -- Record there is no owner now
1653 P
:= Self_ID
.Common
.LL
.Locks
;
1654 Self_ID
.Common
.LL
.Locks
:= Self_ID
.Common
.LL
.Locks
.Next
;
1659 --------------------
1660 -- Check_Finalize --
1661 --------------------
1663 function Check_Finalize_Lock
(L
: Lock_Ptr
) return Boolean is
1664 Self_ID
: constant Task_Id
:= Self
;
1667 -- Check that caller is abort-deferred
1669 if Self_ID
.Deferral_Level
= 0 then
1673 -- Check that no one is holding this lock
1675 if L
.Owner
/= null then
1681 end Check_Finalize_Lock
;
1687 procedure Initialize
(S
: in out Suspension_Object
) is
1688 Result
: Interfaces
.C
.int
;
1691 -- Initialize internal state (always to zero (RM D.10(6)))
1696 -- Initialize internal mutex
1698 Result
:= mutex_init
(S
.L
'Access, USYNC_THREAD
, System
.Null_Address
);
1699 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
1701 if Result
= ENOMEM
then
1702 raise Storage_Error
with "Failed to allocate a lock";
1705 -- Initialize internal condition variable
1707 Result
:= cond_init
(S
.CV
'Access, USYNC_THREAD
, 0);
1708 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
1711 Result
:= mutex_destroy
(S
.L
'Access);
1712 pragma Assert
(Result
= 0);
1714 if Result
= ENOMEM
then
1715 raise Storage_Error
;
1724 procedure Finalize
(S
: in out Suspension_Object
) is
1725 Result
: Interfaces
.C
.int
;
1728 -- Destroy internal mutex
1730 Result
:= mutex_destroy
(S
.L
'Access);
1731 pragma Assert
(Result
= 0);
1733 -- Destroy internal condition variable
1735 Result
:= cond_destroy
(S
.CV
'Access);
1736 pragma Assert
(Result
= 0);
1743 function Current_State
(S
: Suspension_Object
) return Boolean is
1745 -- We do not want to use lock on this read operation. State is marked
1746 -- as Atomic so that we ensure that the value retrieved is correct.
1755 procedure Set_False
(S
: in out Suspension_Object
) is
1756 Result
: Interfaces
.C
.int
;
1759 SSL
.Abort_Defer
.all;
1761 Result
:= mutex_lock
(S
.L
'Access);
1762 pragma Assert
(Result
= 0);
1766 Result
:= mutex_unlock
(S
.L
'Access);
1767 pragma Assert
(Result
= 0);
1769 SSL
.Abort_Undefer
.all;
1776 procedure Set_True
(S
: in out Suspension_Object
) is
1777 Result
: Interfaces
.C
.int
;
1780 SSL
.Abort_Defer
.all;
1782 Result
:= mutex_lock
(S
.L
'Access);
1783 pragma Assert
(Result
= 0);
1785 -- If there is already a task waiting on this suspension object then
1786 -- we resume it, leaving the state of the suspension object to False,
1787 -- as it is specified in ARM D.10 par. 9. Otherwise, it just leaves
1788 -- the state to True.
1794 Result
:= cond_signal
(S
.CV
'Access);
1795 pragma Assert
(Result
= 0);
1801 Result
:= mutex_unlock
(S
.L
'Access);
1802 pragma Assert
(Result
= 0);
1804 SSL
.Abort_Undefer
.all;
1807 ------------------------
1808 -- Suspend_Until_True --
1809 ------------------------
1811 procedure Suspend_Until_True
(S
: in out Suspension_Object
) is
1812 Result
: Interfaces
.C
.int
;
1815 SSL
.Abort_Defer
.all;
1817 Result
:= mutex_lock
(S
.L
'Access);
1818 pragma Assert
(Result
= 0);
1822 -- Program_Error must be raised upon calling Suspend_Until_True
1823 -- if another task is already waiting on that suspension object
1826 Result
:= mutex_unlock
(S
.L
'Access);
1827 pragma Assert
(Result
= 0);
1829 SSL
.Abort_Undefer
.all;
1831 raise Program_Error
;
1834 -- Suspend the task if the state is False. Otherwise, the task
1835 -- continues its execution, and the state of the suspension object
1836 -- is set to False (ARM D.10 par. 9).
1842 Result
:= cond_wait
(S
.CV
'Access, S
.L
'Access);
1845 Result
:= mutex_unlock
(S
.L
'Access);
1846 pragma Assert
(Result
= 0);
1848 SSL
.Abort_Undefer
.all;
1850 end Suspend_Until_True
;
1856 function Check_Exit
(Self_ID
: Task_Id
) return Boolean is
1858 -- Check that caller is just holding Global_Task_Lock and no other locks
1860 if Self_ID
.Common
.LL
.Locks
= null then
1864 -- 2 = Global_Task_Level
1866 if Self_ID
.Common
.LL
.Locks
.Level
/= 2 then
1870 if Self_ID
.Common
.LL
.Locks
.Next
/= null then
1874 -- Check that caller is abort-deferred
1876 if Self_ID
.Deferral_Level
= 0 then
1883 --------------------
1884 -- Check_No_Locks --
1885 --------------------
1887 function Check_No_Locks
(Self_ID
: Task_Id
) return Boolean is
1889 return Self_ID
.Common
.LL
.Locks
= null;
1892 ----------------------
1893 -- Environment_Task --
1894 ----------------------
1896 function Environment_Task
return Task_Id
is
1898 return Environment_Task_Id
;
1899 end Environment_Task
;
1905 procedure Lock_RTS
is
1907 Write_Lock
(Single_RTS_Lock
'Access, Global_Lock
=> True);
1914 procedure Unlock_RTS
is
1916 Unlock
(Single_RTS_Lock
'Access, Global_Lock
=> True);
1923 function Suspend_Task
1925 Thread_Self
: Thread_Id
) return Boolean
1928 if T
.Common
.LL
.Thread
/= Thread_Self
then
1929 return thr_suspend
(T
.Common
.LL
.Thread
) = 0;
1939 function Resume_Task
1941 Thread_Self
: Thread_Id
) return Boolean
1944 if T
.Common
.LL
.Thread
/= Thread_Self
then
1945 return thr_continue
(T
.Common
.LL
.Thread
) = 0;
1951 --------------------
1952 -- Stop_All_Tasks --
1953 --------------------
1955 procedure Stop_All_Tasks
is
1964 function Stop_Task
(T
: ST
.Task_Id
) return Boolean is
1965 pragma Unreferenced
(T
);
1974 function Continue_Task
(T
: ST
.Task_Id
) return Boolean is
1975 pragma Unreferenced
(T
);
1980 end System
.Task_Primitives
.Operations
;