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-2009, 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 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. --
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. --
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/>. --
27 -- GNARL was developed by the GNARL team at Florida State University. --
28 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
30 ------------------------------------------------------------------------------
32 -- This is a Solaris (native) version of this package
34 -- This package contains all the GNULL primitives that interface directly with
38 -- Turn off polling, we do not want ATC polling to take place during tasking
39 -- operations. It causes infinite loops and other problems.
41 with Ada
.Unchecked_Deallocation
;
45 with System
.Tasking
.Debug
;
46 with System
.Interrupt_Management
;
47 with System
.OS_Primitives
;
48 with System
.Task_Info
;
50 pragma Warnings
(Off
);
54 with System
.Soft_Links
;
55 -- We use System.Soft_Links instead of System.Tasking.Initialization
56 -- because the later is a higher level package that we shouldn't depend on.
57 -- For example when using the restricted run time, it is replaced by
58 -- System.Tasking.Restricted.Stages.
60 package body System
.Task_Primitives
.Operations
is
62 package SSL
renames System
.Soft_Links
;
64 use System
.Tasking
.Debug
;
67 use System
.OS_Interface
;
68 use System
.Parameters
;
69 use System
.OS_Primitives
;
75 -- The following are logically constants, but need to be initialized
78 Environment_Task_Id
: Task_Id
;
79 -- A variable to hold Task_Id for the environment task.
80 -- If we use this variable to get the Task_Id, we need the following
81 -- ATCB_Key only for non-Ada threads.
83 Unblocked_Signal_Mask
: aliased sigset_t
;
84 -- The set of signals that should unblocked in all tasks
86 ATCB_Key
: aliased thread_key_t
;
87 -- Key used to find the Ada Task_Id associated with a thread,
88 -- at least for C threads unknown to the Ada run-time system.
90 Single_RTS_Lock
: aliased RTS_Lock
;
91 -- This is a lock to allow only one thread of control in the RTS at
92 -- a time; it is used to execute in mutual exclusion from all other tasks.
93 -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List
95 Next_Serial_Number
: Task_Serial_Number
:= 100;
96 -- We start at 100, to reserve some special values for
97 -- using in error checking.
98 -- The following are internal configuration constants needed.
100 Abort_Handler_Installed
: Boolean := False;
101 -- True if a handler for the abort signal is installed
103 ----------------------
104 -- Priority Support --
105 ----------------------
107 Priority_Ceiling_Emulation
: constant Boolean := True;
108 -- controls whether we emulate priority ceiling locking
110 -- To get a scheduling close to annex D requirements, we use the real-time
111 -- class provided for LWPs and map each task/thread to a specific and
112 -- unique LWP (there is 1 thread per LWP, and 1 LWP per thread).
114 -- The real time class can only be set when the process has root
115 -- privileges, so in the other cases, we use the normal thread scheduling
116 -- and priority handling.
118 Using_Real_Time_Class
: Boolean := False;
119 -- indicates whether the real time class is being used (i.e. the process
120 -- has root privileges).
122 Prio_Param
: aliased struct_pcparms
;
123 -- Hold priority info (Real_Time) initialized during the package
126 -----------------------------------
127 -- External Configuration Values --
128 -----------------------------------
130 Time_Slice_Val
: Integer;
131 pragma Import
(C
, Time_Slice_Val
, "__gl_time_slice_val");
133 Locking_Policy
: Character;
134 pragma Import
(C
, Locking_Policy
, "__gl_locking_policy");
136 Dispatching_Policy
: Character;
137 pragma Import
(C
, Dispatching_Policy
, "__gl_task_dispatching_policy");
139 Foreign_Task_Elaborated
: aliased Boolean := True;
140 -- Used to identified fake tasks (i.e., non-Ada Threads)
142 -----------------------
143 -- Local Subprograms --
144 -----------------------
146 function sysconf
(name
: System
.OS_Interface
.int
) return processorid_t
;
147 pragma Import
(C
, sysconf
, "sysconf");
149 SC_NPROCESSORS_CONF
: constant System
.OS_Interface
.int
:= 14;
152 (name
: System
.OS_Interface
.int
:= SC_NPROCESSORS_CONF
)
153 return processorid_t
renames sysconf
;
155 procedure Abort_Handler
157 Code
: not null access siginfo_t
;
158 Context
: not null access ucontext_t
);
159 -- Target-dependent binding of inter-thread Abort signal to
160 -- the raising of the Abort_Signal exception.
161 -- See also comments in 7staprop.adb
167 function Check_Initialize_Lock
169 Level
: Lock_Level
) return Boolean;
170 pragma Inline
(Check_Initialize_Lock
);
172 function Check_Lock
(L
: Lock_Ptr
) return Boolean;
173 pragma Inline
(Check_Lock
);
175 function Record_Lock
(L
: Lock_Ptr
) return Boolean;
176 pragma Inline
(Record_Lock
);
178 function Check_Sleep
(Reason
: Task_States
) return Boolean;
179 pragma Inline
(Check_Sleep
);
181 function Record_Wakeup
183 Reason
: Task_States
) return Boolean;
184 pragma Inline
(Record_Wakeup
);
186 function Check_Wakeup
188 Reason
: Task_States
) return Boolean;
189 pragma Inline
(Check_Wakeup
);
191 function Check_Unlock
(L
: Lock_Ptr
) return Boolean;
192 pragma Inline
(Check_Unlock
);
194 function Check_Finalize_Lock
(L
: Lock_Ptr
) return Boolean;
195 pragma Inline
(Check_Finalize_Lock
);
203 procedure Initialize
(Environment_Task
: Task_Id
);
204 pragma Inline
(Initialize
);
205 -- Initialize various data needed by this package
207 function Is_Valid_Task
return Boolean;
208 pragma Inline
(Is_Valid_Task
);
209 -- Does executing thread have a TCB?
211 procedure Set
(Self_Id
: Task_Id
);
213 -- Set the self id for the current task
215 function Self
return Task_Id
;
216 pragma Inline
(Self
);
217 -- Return a pointer to the Ada Task Control Block of the calling task
221 package body Specific
is separate;
222 -- The body of this package is target specific
224 ---------------------------------
225 -- Support for foreign threads --
226 ---------------------------------
228 function Register_Foreign_Thread
(Thread
: Thread_Id
) return Task_Id
;
229 -- Allocate and Initialize a new ATCB for the current Thread
231 function Register_Foreign_Thread
232 (Thread
: Thread_Id
) return Task_Id
is separate;
238 Check_Count
: Integer := 0;
239 Lock_Count
: Integer := 0;
240 Unlock_Count
: Integer := 0;
246 procedure Abort_Handler
248 Code
: not null access siginfo_t
;
249 Context
: not null access ucontext_t
)
251 pragma Unreferenced
(Sig
);
252 pragma Unreferenced
(Code
);
253 pragma Unreferenced
(Context
);
255 Self_ID
: constant Task_Id
:= Self
;
256 Old_Set
: aliased sigset_t
;
258 Result
: Interfaces
.C
.int
;
259 pragma Warnings
(Off
, Result
);
262 -- It's not safe to raise an exception when using GCC ZCX mechanism.
263 -- Note that we still need to install a signal handler, since in some
264 -- cases (e.g. shutdown of the Server_Task in System.Interrupts) we
265 -- need to send the Abort signal to a task.
267 if ZCX_By_Default
and then GCC_ZCX_Support
then
271 if Self_ID
.Deferral_Level
= 0
272 and then Self_ID
.Pending_ATC_Level
< Self_ID
.ATC_Nesting_Level
273 and then not Self_ID
.Aborting
275 Self_ID
.Aborting
:= True;
277 -- Make sure signals used for RTS internal purpose are unmasked
282 Unblocked_Signal_Mask
'Unchecked_Access,
283 Old_Set
'Unchecked_Access);
284 pragma Assert
(Result
= 0);
286 raise Standard
'Abort_Signal;
294 -- The underlying thread system sets a guard page at the
295 -- bottom of a thread stack, so nothing is needed.
297 procedure Stack_Guard
(T
: ST
.Task_Id
; On
: Boolean) is
298 pragma Unreferenced
(T
);
299 pragma Unreferenced
(On
);
308 function Get_Thread_Id
(T
: ST
.Task_Id
) return OSI
.Thread_Id
is
310 return T
.Common
.LL
.Thread
;
317 procedure Initialize
(Environment_Task
: ST
.Task_Id
) is
318 act
: aliased struct_sigaction
;
319 old_act
: aliased struct_sigaction
;
320 Tmp_Set
: aliased sigset_t
;
321 Result
: Interfaces
.C
.int
;
323 procedure Configure_Processors
;
324 -- Processors configuration
325 -- The user can specify a processor which the program should run
326 -- on to emulate a single-processor system. This can be easily
327 -- done by setting environment variable GNAT_PROCESSOR to one of
330 -- -2 : use the default configuration (run the program on all
331 -- available processors) - this is the same as having
332 -- GNAT_PROCESSOR unset
333 -- -1 : let the RTS choose one processor and run the program on
335 -- 0 .. Last_Proc : run the program on the specified processor
337 -- Last_Proc is equal to the value of the system variable
338 -- _SC_NPROCESSORS_CONF, minus one.
340 procedure Configure_Processors
is
341 Proc_Acc
: constant System
.OS_Lib
.String_Access
:=
342 System
.OS_Lib
.Getenv
("GNAT_PROCESSOR");
343 Proc
: aliased processorid_t
; -- User processor #
344 Last_Proc
: processorid_t
; -- Last processor #
347 if Proc_Acc
.all'Length /= 0 then
349 -- Environment variable is defined
351 Last_Proc
:= Num_Procs
- 1;
353 if Last_Proc
/= -1 then
354 Proc
:= processorid_t
'Value (Proc_Acc
.all);
356 if Proc
<= -2 or else Proc
> Last_Proc
then
358 -- Use the default configuration
364 -- Choose a processor
367 while Proc
< Last_Proc
loop
369 Result
:= p_online
(Proc
, PR_STATUS
);
370 exit when Result
= PR_ONLINE
;
373 pragma Assert
(Result
= PR_ONLINE
);
374 Result
:= processor_bind
(P_PID
, P_MYID
, Proc
, null);
375 pragma Assert
(Result
= 0);
378 -- Use user processor
380 Result
:= processor_bind
(P_PID
, P_MYID
, Proc
, null);
381 pragma Assert
(Result
= 0);
387 when Constraint_Error
=>
389 -- Illegal environment variable GNAT_PROCESSOR - ignored
392 end Configure_Processors
;
395 (Int
: System
.Interrupt_Management
.Interrupt_ID
) return Character;
396 pragma Import
(C
, State
, "__gnat_get_interrupt_state");
397 -- Get interrupt state. Defined in a-init.c
398 -- The input argument is the interrupt number,
399 -- and the result is one of the following:
401 Default
: constant Character := 's';
402 -- 'n' this interrupt not set by any Interrupt_State pragma
403 -- 'u' Interrupt_State pragma set state to User
404 -- 'r' Interrupt_State pragma set state to Runtime
405 -- 's' Interrupt_State pragma set state to System (use "default"
408 -- Start of processing for Initialize
411 Environment_Task_Id
:= Environment_Task
;
413 Interrupt_Management
.Initialize
;
415 -- Prepare the set of signals that should unblocked in all tasks
417 Result
:= sigemptyset
(Unblocked_Signal_Mask
'Access);
418 pragma Assert
(Result
= 0);
420 for J
in Interrupt_Management
.Interrupt_ID
loop
421 if System
.Interrupt_Management
.Keep_Unmasked
(J
) then
422 Result
:= sigaddset
(Unblocked_Signal_Mask
'Access, Signal
(J
));
423 pragma Assert
(Result
= 0);
427 if Dispatching_Policy
= 'F' then
429 Result
: Interfaces
.C
.long
;
430 Class_Info
: aliased struct_pcinfo
;
431 Secs
, Nsecs
: Interfaces
.C
.long
;
434 -- If a pragma Time_Slice is specified, takes the value in account
436 if Time_Slice_Val
> 0 then
438 -- Convert Time_Slice_Val (microseconds) to seconds/nanosecs
440 Secs
:= Interfaces
.C
.long
(Time_Slice_Val
/ 1_000_000
);
442 Interfaces
.C
.long
((Time_Slice_Val
rem 1_000_000
) * 1_000
);
444 -- Otherwise, default to no time slicing (i.e run until blocked)
451 -- Get the real time class id
453 Class_Info
.pc_clname
(1) := 'R';
454 Class_Info
.pc_clname
(2) := 'T';
455 Class_Info
.pc_clname
(3) := ASCII
.NUL
;
457 Result
:= priocntl
(PC_VERSION
, P_LWPID
, P_MYID
, PC_GETCID
,
460 -- Request the real time class
462 Prio_Param
.pc_cid
:= Class_Info
.pc_cid
;
463 Prio_Param
.rt_pri
:= pri_t
(Class_Info
.rt_maxpri
);
464 Prio_Param
.rt_tqsecs
:= Secs
;
465 Prio_Param
.rt_tqnsecs
:= Nsecs
;
469 (PC_VERSION
, P_LWPID
, P_MYID
, PC_SETPARMS
, Prio_Param
'Address);
471 Using_Real_Time_Class
:= Result
/= -1;
475 Specific
.Initialize
(Environment_Task
);
477 -- The following is done in Enter_Task, but this is too late for the
478 -- Environment Task, since we need to call Self in Check_Locks when
479 -- the run time is compiled with assertions on.
481 Specific
.Set
(Environment_Task
);
483 -- Initialize the lock used to synchronize chain of all ATCBs
485 Initialize_Lock
(Single_RTS_Lock
'Access, RTS_Lock_Level
);
487 -- Make environment task known here because it doesn't go through
488 -- Activate_Tasks, which does it for all other tasks.
490 Known_Tasks
(Known_Tasks
'First) := Environment_Task
;
491 Environment_Task
.Known_Tasks_Index
:= Known_Tasks
'First;
493 Enter_Task
(Environment_Task
);
495 Configure_Processors
;
498 (System
.Interrupt_Management
.Abort_Task_Interrupt
) /= Default
500 -- Set sa_flags to SA_NODEFER so that during the handler execution
501 -- we do not change the Signal_Mask to be masked for the Abort_Signal
502 -- This is a temporary fix to the problem that the Signal_Mask is
503 -- not restored after the exception (longjmp) from the handler.
504 -- The right fix should be made in sigsetjmp so that we save
505 -- the Signal_Set and restore it after a longjmp.
506 -- In that case, this field should be changed back to 0. ???
510 act
.sa_handler
:= Abort_Handler
'Address;
511 Result
:= sigemptyset
(Tmp_Set
'Access);
512 pragma Assert
(Result
= 0);
513 act
.sa_mask
:= Tmp_Set
;
517 (Signal
(System
.Interrupt_Management
.Abort_Task_Interrupt
),
518 act
'Unchecked_Access,
519 old_act
'Unchecked_Access);
520 pragma Assert
(Result
= 0);
521 Abort_Handler_Installed
:= True;
525 ---------------------
526 -- Initialize_Lock --
527 ---------------------
529 -- Note: mutexes and cond_variables needed per-task basis are initialized
530 -- in Initialize_TCB and the Storage_Error is handled. Other mutexes (such
531 -- as RTS_Lock, Memory_Lock...) used in RTS is initialized before any
532 -- status change of RTS. Therefore raising Storage_Error in the following
533 -- routines should be able to be handled safely.
535 procedure Initialize_Lock
536 (Prio
: System
.Any_Priority
;
537 L
: not null access Lock
)
539 Result
: Interfaces
.C
.int
;
542 pragma Assert
(Check_Initialize_Lock
(Lock_Ptr
(L
), PO_Level
));
544 if Priority_Ceiling_Emulation
then
548 Result
:= mutex_init
(L
.L
'Access, USYNC_THREAD
, System
.Null_Address
);
549 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
551 if Result
= ENOMEM
then
552 raise Storage_Error
with "Failed to allocate a lock";
556 procedure Initialize_Lock
557 (L
: not null access RTS_Lock
;
560 Result
: Interfaces
.C
.int
;
564 (Check_Initialize_Lock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
)), Level
));
565 Result
:= mutex_init
(L
.L
'Access, USYNC_THREAD
, System
.Null_Address
);
566 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
568 if Result
= ENOMEM
then
569 raise Storage_Error
with "Failed to allocate a lock";
577 procedure Finalize_Lock
(L
: not null access Lock
) is
578 Result
: Interfaces
.C
.int
;
580 pragma Assert
(Check_Finalize_Lock
(Lock_Ptr
(L
)));
581 Result
:= mutex_destroy
(L
.L
'Access);
582 pragma Assert
(Result
= 0);
585 procedure Finalize_Lock
(L
: not null access RTS_Lock
) is
586 Result
: Interfaces
.C
.int
;
588 pragma Assert
(Check_Finalize_Lock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
))));
589 Result
:= mutex_destroy
(L
.L
'Access);
590 pragma Assert
(Result
= 0);
598 (L
: not null access Lock
;
599 Ceiling_Violation
: out Boolean)
601 Result
: Interfaces
.C
.int
;
604 pragma Assert
(Check_Lock
(Lock_Ptr
(L
)));
606 if Priority_Ceiling_Emulation
and then Locking_Policy
= 'C' then
608 Self_Id
: constant Task_Id
:= Self
;
609 Saved_Priority
: System
.Any_Priority
;
612 if Self_Id
.Common
.LL
.Active_Priority
> L
.Ceiling
then
613 Ceiling_Violation
:= True;
617 Saved_Priority
:= Self_Id
.Common
.LL
.Active_Priority
;
619 if Self_Id
.Common
.LL
.Active_Priority
< L
.Ceiling
then
620 Set_Priority
(Self_Id
, L
.Ceiling
);
623 Result
:= mutex_lock
(L
.L
'Access);
624 pragma Assert
(Result
= 0);
625 Ceiling_Violation
:= False;
627 L
.Saved_Priority
:= Saved_Priority
;
631 Result
:= mutex_lock
(L
.L
'Access);
632 pragma Assert
(Result
= 0);
633 Ceiling_Violation
:= False;
636 pragma Assert
(Record_Lock
(Lock_Ptr
(L
)));
640 (L
: not null access RTS_Lock
;
641 Global_Lock
: Boolean := False)
643 Result
: Interfaces
.C
.int
;
645 if not Single_Lock
or else Global_Lock
then
646 pragma Assert
(Check_Lock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
))));
647 Result
:= mutex_lock
(L
.L
'Access);
648 pragma Assert
(Result
= 0);
649 pragma Assert
(Record_Lock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
))));
653 procedure Write_Lock
(T
: Task_Id
) is
654 Result
: Interfaces
.C
.int
;
656 if not Single_Lock
then
657 pragma Assert
(Check_Lock
(To_Lock_Ptr
(T
.Common
.LL
.L
'Access)));
658 Result
:= mutex_lock
(T
.Common
.LL
.L
.L
'Access);
659 pragma Assert
(Result
= 0);
660 pragma Assert
(Record_Lock
(To_Lock_Ptr
(T
.Common
.LL
.L
'Access)));
669 (L
: not null access Lock
;
670 Ceiling_Violation
: out Boolean) is
672 Write_Lock
(L
, Ceiling_Violation
);
679 procedure Unlock
(L
: not null access Lock
) is
680 Result
: Interfaces
.C
.int
;
683 pragma Assert
(Check_Unlock
(Lock_Ptr
(L
)));
685 if Priority_Ceiling_Emulation
and then Locking_Policy
= 'C' then
687 Self_Id
: constant Task_Id
:= Self
;
690 Result
:= mutex_unlock
(L
.L
'Access);
691 pragma Assert
(Result
= 0);
693 if Self_Id
.Common
.LL
.Active_Priority
> L
.Saved_Priority
then
694 Set_Priority
(Self_Id
, L
.Saved_Priority
);
698 Result
:= mutex_unlock
(L
.L
'Access);
699 pragma Assert
(Result
= 0);
704 (L
: not null access RTS_Lock
;
705 Global_Lock
: Boolean := False)
707 Result
: Interfaces
.C
.int
;
709 if not Single_Lock
or else Global_Lock
then
710 pragma Assert
(Check_Unlock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
))));
711 Result
:= mutex_unlock
(L
.L
'Access);
712 pragma Assert
(Result
= 0);
716 procedure Unlock
(T
: Task_Id
) is
717 Result
: Interfaces
.C
.int
;
719 if not Single_Lock
then
720 pragma Assert
(Check_Unlock
(To_Lock_Ptr
(T
.Common
.LL
.L
'Access)));
721 Result
:= mutex_unlock
(T
.Common
.LL
.L
.L
'Access);
722 pragma Assert
(Result
= 0);
730 -- Dynamic priority ceilings are not supported by the underlying system
732 procedure Set_Ceiling
733 (L
: not null access Lock
;
734 Prio
: System
.Any_Priority
)
736 pragma Unreferenced
(L
, Prio
);
741 -- For the time delay implementation, we need to make sure we
742 -- achieve following criteria:
744 -- 1) We have to delay at least for the amount requested.
745 -- 2) We have to give up CPU even though the actual delay does not
746 -- result in blocking.
747 -- 3) Except for restricted run-time systems that do not support
748 -- ATC or task abort, the delay must be interrupted by the
749 -- abort_task operation.
750 -- 4) The implementation has to be efficient so that the delay overhead
751 -- is relatively cheap.
752 -- (1)-(3) are Ada requirements. Even though (2) is an Annex-D
753 -- requirement we still want to provide the effect in all cases.
754 -- The reason is that users may want to use short delays to implement
755 -- their own scheduling effect in the absence of language provided
756 -- scheduling policies.
758 ---------------------
759 -- Monotonic_Clock --
760 ---------------------
762 function Monotonic_Clock
return Duration is
763 TS
: aliased timespec
;
764 Result
: Interfaces
.C
.int
;
766 Result
:= clock_gettime
(CLOCK_REALTIME
, TS
'Unchecked_Access);
767 pragma Assert
(Result
= 0);
768 return To_Duration
(TS
);
775 function RT_Resolution
return Duration is
784 procedure Yield
(Do_Yield
: Boolean := True) is
787 System
.OS_Interface
.thr_yield
;
795 function Self
return Task_Id
renames Specific
.Self
;
801 procedure Set_Priority
803 Prio
: System
.Any_Priority
;
804 Loss_Of_Inheritance
: Boolean := False)
806 pragma Unreferenced
(Loss_Of_Inheritance
);
808 Result
: Interfaces
.C
.int
;
809 pragma Unreferenced
(Result
);
811 Param
: aliased struct_pcparms
;
816 T
.Common
.Current_Priority
:= Prio
;
818 if Priority_Ceiling_Emulation
then
819 T
.Common
.LL
.Active_Priority
:= Prio
;
822 if Using_Real_Time_Class
then
823 Param
.pc_cid
:= Prio_Param
.pc_cid
;
824 Param
.rt_pri
:= pri_t
(Prio
);
825 Param
.rt_tqsecs
:= Prio_Param
.rt_tqsecs
;
826 Param
.rt_tqnsecs
:= Prio_Param
.rt_tqnsecs
;
828 Result
:= Interfaces
.C
.int
(
829 priocntl
(PC_VERSION
, P_LWPID
, T
.Common
.LL
.LWP
, PC_SETPARMS
,
833 if T
.Common
.Task_Info
/= null
834 and then not T
.Common
.Task_Info
.Bound_To_LWP
836 -- The task is not bound to a LWP, so use thr_setprio
839 thr_setprio
(T
.Common
.LL
.Thread
, Interfaces
.C
.int
(Prio
));
842 -- The task is bound to a LWP, use priocntl
854 function Get_Priority
(T
: Task_Id
) return System
.Any_Priority
is
856 return T
.Common
.Current_Priority
;
863 procedure Enter_Task
(Self_ID
: Task_Id
) is
864 Result
: Interfaces
.C
.int
;
865 Proc
: processorid_t
; -- User processor #
866 Last_Proc
: processorid_t
; -- Last processor #
868 use System
.Task_Info
;
870 Self_ID
.Common
.LL
.Thread
:= thr_self
;
872 Self_ID
.Common
.LL
.LWP
:= lwp_self
;
874 if Self_ID
.Common
.Task_Info
/= null then
875 if Self_ID
.Common
.Task_Info
.New_LWP
876 and then Self_ID
.Common
.Task_Info
.CPU
/= CPU_UNCHANGED
878 Last_Proc
:= Num_Procs
- 1;
880 if Self_ID
.Common
.Task_Info
.CPU
= ANY_CPU
then
883 while Proc
< Last_Proc
loop
884 Result
:= p_online
(Proc
, PR_STATUS
);
885 exit when Result
= PR_ONLINE
;
889 Result
:= processor_bind
(P_LWPID
, P_MYID
, Proc
, null);
890 pragma Assert
(Result
= 0);
893 -- Use specified processor
895 if Self_ID
.Common
.Task_Info
.CPU
< 0
896 or else Self_ID
.Common
.Task_Info
.CPU
> Last_Proc
898 raise Invalid_CPU_Number
;
903 (P_LWPID
, P_MYID
, Self_ID
.Common
.Task_Info
.CPU
, null);
904 pragma Assert
(Result
= 0);
909 Specific
.Set
(Self_ID
);
911 -- We need the above code even if we do direct fetch of Task_Id in Self
912 -- for the main task on Sun, x86 Solaris and for gcc 2.7.2.
919 function New_ATCB
(Entry_Num
: Task_Entry_Index
) return Task_Id
is
921 return new Ada_Task_Control_Block
(Entry_Num
);
928 function Is_Valid_Task
return Boolean renames Specific
.Is_Valid_Task
;
930 -----------------------------
931 -- Register_Foreign_Thread --
932 -----------------------------
934 function Register_Foreign_Thread
return Task_Id
is
936 if Is_Valid_Task
then
939 return Register_Foreign_Thread
(thr_self
);
941 end Register_Foreign_Thread
;
947 procedure Initialize_TCB
(Self_ID
: Task_Id
; Succeeded
: out Boolean) is
948 Result
: Interfaces
.C
.int
:= 0;
951 -- Give the task a unique serial number
953 Self_ID
.Serial_Number
:= Next_Serial_Number
;
954 Next_Serial_Number
:= Next_Serial_Number
+ 1;
955 pragma Assert
(Next_Serial_Number
/= 0);
957 Self_ID
.Common
.LL
.Thread
:= To_thread_t
(-1);
959 if not Single_Lock
then
962 (Self_ID
.Common
.LL
.L
.L
'Access, USYNC_THREAD
, System
.Null_Address
);
963 Self_ID
.Common
.LL
.L
.Level
:=
964 Private_Task_Serial_Number
(Self_ID
.Serial_Number
);
965 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
969 Result
:= cond_init
(Self_ID
.Common
.LL
.CV
'Access, USYNC_THREAD
, 0);
970 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
976 if not Single_Lock
then
977 Result
:= mutex_destroy
(Self_ID
.Common
.LL
.L
.L
'Access);
978 pragma Assert
(Result
= 0);
989 procedure Create_Task
991 Wrapper
: System
.Address
;
992 Stack_Size
: System
.Parameters
.Size_Type
;
993 Priority
: System
.Any_Priority
;
994 Succeeded
: out Boolean)
996 pragma Unreferenced
(Priority
);
998 Result
: Interfaces
.C
.int
;
999 Adjusted_Stack_Size
: Interfaces
.C
.size_t
;
1000 Opts
: Interfaces
.C
.int
:= THR_DETACHED
;
1002 Page_Size
: constant System
.Parameters
.Size_Type
:= 4096;
1003 -- This constant is for reserving extra space at the
1004 -- end of the stack, which can be used by the stack
1005 -- checking as guard page. The idea is that we need
1006 -- to have at least Stack_Size bytes available for
1009 use System
.Task_Info
;
1012 Adjusted_Stack_Size
:= Interfaces
.C
.size_t
(Stack_Size
+ Page_Size
);
1014 -- Since the initial signal mask of a thread is inherited from the
1015 -- creator, and the Environment task has all its signals masked, we
1016 -- do not need to manipulate caller's signal mask at this point.
1017 -- All tasks in RTS will have All_Tasks_Mask initially.
1019 if T
.Common
.Task_Info
/= null then
1020 if T
.Common
.Task_Info
.New_LWP
then
1021 Opts
:= Opts
+ THR_NEW_LWP
;
1024 if T
.Common
.Task_Info
.Bound_To_LWP
then
1025 Opts
:= Opts
+ THR_BOUND
;
1029 Opts
:= THR_DETACHED
+ THR_BOUND
;
1034 (System
.Null_Address
,
1035 Adjusted_Stack_Size
,
1036 Thread_Body_Access
(Wrapper
),
1039 T
.Common
.LL
.Thread
'Access);
1041 Succeeded
:= Result
= 0;
1044 or else Result
= ENOMEM
1045 or else Result
= EAGAIN
);
1052 procedure Finalize_TCB
(T
: Task_Id
) is
1053 Result
: Interfaces
.C
.int
;
1055 Is_Self
: constant Boolean := T
= Self
;
1057 procedure Free
is new
1058 Ada
.Unchecked_Deallocation
(Ada_Task_Control_Block
, Task_Id
);
1061 T
.Common
.LL
.Thread
:= To_thread_t
(0);
1063 if not Single_Lock
then
1064 Result
:= mutex_destroy
(T
.Common
.LL
.L
.L
'Access);
1065 pragma Assert
(Result
= 0);
1068 Result
:= cond_destroy
(T
.Common
.LL
.CV
'Access);
1069 pragma Assert
(Result
= 0);
1071 if T
.Known_Tasks_Index
/= -1 then
1072 Known_Tasks
(T
.Known_Tasks_Index
) := null;
1078 Specific
.Set
(null);
1086 -- This procedure must be called with abort deferred. It can no longer
1087 -- call Self or access the current task's ATCB, since the ATCB has been
1090 procedure Exit_Task
is
1092 Specific
.Set
(null);
1099 procedure Abort_Task
(T
: Task_Id
) is
1100 Result
: Interfaces
.C
.int
;
1102 if Abort_Handler_Installed
then
1103 pragma Assert
(T
/= Self
);
1106 (T
.Common
.LL
.Thread
,
1107 Signal
(System
.Interrupt_Management
.Abort_Task_Interrupt
));
1108 pragma Assert
(Result
= 0);
1118 Reason
: Task_States
)
1120 Result
: Interfaces
.C
.int
;
1123 pragma Assert
(Check_Sleep
(Reason
));
1128 (Self_ID
.Common
.LL
.CV
'Access, Single_RTS_Lock
.L
'Access);
1132 (Self_ID
.Common
.LL
.CV
'Access, Self_ID
.Common
.LL
.L
.L
'Access);
1136 (Record_Wakeup
(To_Lock_Ptr
(Self_ID
.Common
.LL
.L
'Access), Reason
));
1137 pragma Assert
(Result
= 0 or else Result
= EINTR
);
1140 -- Note that we are relying heavily here on GNAT representing
1141 -- Calendar.Time, System.Real_Time.Time, Duration,
1142 -- System.Real_Time.Time_Span in the same way, i.e., as a 64-bit count of
1145 -- This allows us to always pass the timeout value as a Duration
1148 -- We are taking liberties here with the semantics of the delays. That is,
1149 -- we make no distinction between delays on the Calendar clock and delays
1150 -- on the Real_Time clock. That is technically incorrect, if the Calendar
1151 -- clock happens to be reset or adjusted. To solve this defect will require
1152 -- modification to the compiler interface, so that it can pass through more
1153 -- information, to tell us here which clock to use!
1155 -- cond_timedwait will return if any of the following happens:
1156 -- 1) some other task did cond_signal on this condition variable
1157 -- In this case, the return value is 0
1158 -- 2) the call just returned, for no good reason
1159 -- This is called a "spurious wakeup".
1160 -- In this case, the return value may also be 0.
1161 -- 3) the time delay expires
1162 -- In this case, the return value is ETIME
1163 -- 4) this task received a signal, which was handled by some
1164 -- handler procedure, and now the thread is resuming execution
1165 -- UNIX calls this an "interrupted" system call.
1166 -- In this case, the return value is EINTR
1168 -- If the cond_timedwait returns 0 or EINTR, it is still possible that the
1169 -- time has actually expired, and by chance a signal or cond_signal
1170 -- occurred at around the same time.
1172 -- We have also observed that on some OS's the value ETIME will be
1173 -- returned, but the clock will show that the full delay has not yet
1176 -- For these reasons, we need to check the clock after return from
1177 -- cond_timedwait. If the time has expired, we will set Timedout = True.
1179 -- This check might be omitted for systems on which the cond_timedwait()
1180 -- never returns early or wakes up spuriously.
1182 -- Annex D requires that completion of a delay cause the task to go to the
1183 -- end of its priority queue, regardless of whether the task actually was
1184 -- suspended by the delay. Since cond_timedwait does not do this on
1185 -- Solaris, we add a call to thr_yield at the end. We might do this at the
1186 -- beginning, instead, but then the round-robin effect would not be the
1187 -- same; the delayed task would be ahead of other tasks of the same
1188 -- priority that awoke while it was sleeping.
1190 -- For Timed_Sleep, we are expecting possible cond_signals to indicate
1191 -- other events (e.g., completion of a RV or completion of the abortable
1192 -- part of an async. select), we want to always return if interrupted. The
1193 -- caller will be responsible for checking the task state to see whether
1194 -- the wakeup was spurious, and to go back to sleep again in that case. We
1195 -- don't need to check for pending abort or priority change on the way in
1196 -- our out; that is the caller's responsibility.
1198 -- For Timed_Delay, we are not expecting any cond_signals or other
1199 -- interruptions, except for priority changes and aborts. Therefore, we
1200 -- don't want to return unless the delay has actually expired, or the call
1201 -- has been aborted. In this case, since we want to implement the entire
1202 -- delay statement semantics, we do need to check for pending abort and
1203 -- priority changes. We can quietly handle priority changes inside the
1204 -- procedure, since there is no entry-queue reordering involved.
1210 procedure Timed_Sleep
1213 Mode
: ST
.Delay_Modes
;
1214 Reason
: System
.Tasking
.Task_States
;
1215 Timedout
: out Boolean;
1216 Yielded
: out Boolean)
1218 Base_Time
: constant Duration := Monotonic_Clock
;
1219 Check_Time
: Duration := Base_Time
;
1220 Abs_Time
: Duration;
1221 Request
: aliased timespec
;
1222 Result
: Interfaces
.C
.int
;
1225 pragma Assert
(Check_Sleep
(Reason
));
1231 then Duration'Min (Time
, Max_Sensible_Delay
) + Check_Time
1232 else Duration'Min (Check_Time
+ Max_Sensible_Delay
, Time
));
1234 if Abs_Time
> Check_Time
then
1235 Request
:= To_Timespec
(Abs_Time
);
1237 exit when Self_ID
.Pending_ATC_Level
< Self_ID
.ATC_Nesting_Level
;
1242 (Self_ID
.Common
.LL
.CV
'Access,
1243 Single_RTS_Lock
.L
'Access, Request
'Access);
1247 (Self_ID
.Common
.LL
.CV
'Access,
1248 Self_ID
.Common
.LL
.L
.L
'Access, Request
'Access);
1253 Check_Time
:= Monotonic_Clock
;
1254 exit when Abs_Time
<= Check_Time
or else Check_Time
< Base_Time
;
1256 if Result
= 0 or Result
= EINTR
then
1258 -- Somebody may have called Wakeup for us
1264 pragma Assert
(Result
= ETIME
);
1269 (Record_Wakeup
(To_Lock_Ptr
(Self_ID
.Common
.LL
.L
'Access), Reason
));
1276 procedure Timed_Delay
1279 Mode
: ST
.Delay_Modes
)
1281 Base_Time
: constant Duration := Monotonic_Clock
;
1282 Check_Time
: Duration := Base_Time
;
1283 Abs_Time
: Duration;
1284 Request
: aliased timespec
;
1285 Result
: Interfaces
.C
.int
;
1286 Yielded
: Boolean := False;
1293 Write_Lock
(Self_ID
);
1297 then Time
+ Check_Time
1298 else Duration'Min (Check_Time
+ Max_Sensible_Delay
, Time
));
1300 if Abs_Time
> Check_Time
then
1301 Request
:= To_Timespec
(Abs_Time
);
1302 Self_ID
.Common
.State
:= Delay_Sleep
;
1304 pragma Assert
(Check_Sleep
(Delay_Sleep
));
1307 exit when Self_ID
.Pending_ATC_Level
< Self_ID
.ATC_Nesting_Level
;
1312 (Self_ID
.Common
.LL
.CV
'Access,
1313 Single_RTS_Lock
.L
'Access,
1318 (Self_ID
.Common
.LL
.CV
'Access,
1319 Self_ID
.Common
.LL
.L
.L
'Access,
1325 Check_Time
:= Monotonic_Clock
;
1326 exit when Abs_Time
<= Check_Time
or else Check_Time
< Base_Time
;
1330 Result
= ETIME
or else
1336 (To_Lock_Ptr
(Self_ID
.Common
.LL
.L
'Access), Delay_Sleep
));
1338 Self_ID
.Common
.State
:= Runnable
;
1358 Reason
: Task_States
)
1360 Result
: Interfaces
.C
.int
;
1362 pragma Assert
(Check_Wakeup
(T
, Reason
));
1363 Result
:= cond_signal
(T
.Common
.LL
.CV
'Access);
1364 pragma Assert
(Result
= 0);
1367 ---------------------------
1368 -- Check_Initialize_Lock --
1369 ---------------------------
1371 -- The following code is intended to check some of the invariant assertions
1372 -- related to lock usage, on which we depend.
1374 function Check_Initialize_Lock
1376 Level
: Lock_Level
) return Boolean
1378 Self_ID
: constant Task_Id
:= Self
;
1381 -- Check that caller is abort-deferred
1383 if Self_ID
.Deferral_Level
= 0 then
1387 -- Check that the lock is not yet initialized
1389 if L
.Level
/= 0 then
1393 L
.Level
:= Lock_Level
'Pos (Level
) + 1;
1395 end Check_Initialize_Lock
;
1401 function Check_Lock
(L
: Lock_Ptr
) return Boolean is
1402 Self_ID
: constant Task_Id
:= Self
;
1406 -- Check that the argument is not null
1412 -- Check that L is not frozen
1418 -- Check that caller is abort-deferred
1420 if Self_ID
.Deferral_Level
= 0 then
1424 -- Check that caller is not holding this lock already
1426 if L
.Owner
= To_Owner_ID
(To_Address
(Self_ID
)) then
1434 -- Check that TCB lock order rules are satisfied
1436 P
:= Self_ID
.Common
.LL
.Locks
;
1438 if P
.Level
>= L
.Level
1439 and then (P
.Level
> 2 or else L
.Level
> 2)
1452 function Record_Lock
(L
: Lock_Ptr
) return Boolean is
1453 Self_ID
: constant Task_Id
:= Self
;
1457 Lock_Count
:= Lock_Count
+ 1;
1459 -- There should be no owner for this lock at this point
1461 if L
.Owner
/= null then
1467 L
.Owner
:= To_Owner_ID
(To_Address
(Self_ID
));
1473 -- Check that TCB lock order rules are satisfied
1475 P
:= Self_ID
.Common
.LL
.Locks
;
1481 Self_ID
.Common
.LL
.Locking
:= null;
1482 Self_ID
.Common
.LL
.Locks
:= L
;
1490 function Check_Sleep
(Reason
: Task_States
) return Boolean is
1491 pragma Unreferenced
(Reason
);
1493 Self_ID
: constant Task_Id
:= Self
;
1497 -- Check that caller is abort-deferred
1499 if Self_ID
.Deferral_Level
= 0 then
1507 -- Check that caller is holding own lock, on top of list
1509 if Self_ID
.Common
.LL
.Locks
/=
1510 To_Lock_Ptr
(Self_ID
.Common
.LL
.L
'Access)
1515 -- Check that TCB lock order rules are satisfied
1517 if Self_ID
.Common
.LL
.Locks
.Next
/= null then
1521 Self_ID
.Common
.LL
.L
.Owner
:= null;
1522 P
:= Self_ID
.Common
.LL
.Locks
;
1523 Self_ID
.Common
.LL
.Locks
:= Self_ID
.Common
.LL
.Locks
.Next
;
1532 function Record_Wakeup
1534 Reason
: Task_States
) return Boolean
1536 pragma Unreferenced
(Reason
);
1538 Self_ID
: constant Task_Id
:= Self
;
1544 L
.Owner
:= To_Owner_ID
(To_Address
(Self_ID
));
1550 -- Check that TCB lock order rules are satisfied
1552 P
:= Self_ID
.Common
.LL
.Locks
;
1558 Self_ID
.Common
.LL
.Locking
:= null;
1559 Self_ID
.Common
.LL
.Locks
:= L
;
1567 function Check_Wakeup
1569 Reason
: Task_States
) return Boolean
1571 Self_ID
: constant Task_Id
:= Self
;
1574 -- Is caller holding T's lock?
1576 if T
.Common
.LL
.L
.Owner
/= To_Owner_ID
(To_Address
(Self_ID
)) then
1580 -- Are reasons for wakeup and sleep consistent?
1582 if T
.Common
.State
/= Reason
then
1593 function Check_Unlock
(L
: Lock_Ptr
) return Boolean is
1594 Self_ID
: constant Task_Id
:= Self
;
1598 Unlock_Count
:= Unlock_Count
+ 1;
1604 if L
.Buddy
/= null then
1608 -- Magic constant 4???
1611 Check_Count
:= Unlock_Count
;
1614 -- Magic constant 1000???
1616 if Unlock_Count
- Check_Count
> 1000 then
1617 Check_Count
:= Unlock_Count
;
1620 -- Check that caller is abort-deferred
1622 if Self_ID
.Deferral_Level
= 0 then
1626 -- Check that caller is holding this lock, on top of list
1628 if Self_ID
.Common
.LL
.Locks
/= L
then
1632 -- Record there is no owner now
1635 P
:= Self_ID
.Common
.LL
.Locks
;
1636 Self_ID
.Common
.LL
.Locks
:= Self_ID
.Common
.LL
.Locks
.Next
;
1641 --------------------
1642 -- Check_Finalize --
1643 --------------------
1645 function Check_Finalize_Lock
(L
: Lock_Ptr
) return Boolean is
1646 Self_ID
: constant Task_Id
:= Self
;
1649 -- Check that caller is abort-deferred
1651 if Self_ID
.Deferral_Level
= 0 then
1655 -- Check that no one is holding this lock
1657 if L
.Owner
/= null then
1663 end Check_Finalize_Lock
;
1669 procedure Initialize
(S
: in out Suspension_Object
) is
1670 Result
: Interfaces
.C
.int
;
1673 -- Initialize internal state (always to zero (RM D.10(6)))
1678 -- Initialize internal mutex
1680 Result
:= mutex_init
(S
.L
'Access, USYNC_THREAD
, System
.Null_Address
);
1681 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
1683 if Result
= ENOMEM
then
1684 raise Storage_Error
with "Failed to allocate a lock";
1687 -- Initialize internal condition variable
1689 Result
:= cond_init
(S
.CV
'Access, USYNC_THREAD
, 0);
1690 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
1693 Result
:= mutex_destroy
(S
.L
'Access);
1694 pragma Assert
(Result
= 0);
1696 if Result
= ENOMEM
then
1697 raise Storage_Error
;
1706 procedure Finalize
(S
: in out Suspension_Object
) is
1707 Result
: Interfaces
.C
.int
;
1710 -- Destroy internal mutex
1712 Result
:= mutex_destroy
(S
.L
'Access);
1713 pragma Assert
(Result
= 0);
1715 -- Destroy internal condition variable
1717 Result
:= cond_destroy
(S
.CV
'Access);
1718 pragma Assert
(Result
= 0);
1725 function Current_State
(S
: Suspension_Object
) return Boolean is
1727 -- We do not want to use lock on this read operation. State is marked
1728 -- as Atomic so that we ensure that the value retrieved is correct.
1737 procedure Set_False
(S
: in out Suspension_Object
) is
1738 Result
: Interfaces
.C
.int
;
1741 SSL
.Abort_Defer
.all;
1743 Result
:= mutex_lock
(S
.L
'Access);
1744 pragma Assert
(Result
= 0);
1748 Result
:= mutex_unlock
(S
.L
'Access);
1749 pragma Assert
(Result
= 0);
1751 SSL
.Abort_Undefer
.all;
1758 procedure Set_True
(S
: in out Suspension_Object
) is
1759 Result
: Interfaces
.C
.int
;
1762 SSL
.Abort_Defer
.all;
1764 Result
:= mutex_lock
(S
.L
'Access);
1765 pragma Assert
(Result
= 0);
1767 -- If there is already a task waiting on this suspension object then
1768 -- we resume it, leaving the state of the suspension object to False,
1769 -- as it is specified in ARM D.10 par. 9. Otherwise, it just leaves
1770 -- the state to True.
1776 Result
:= cond_signal
(S
.CV
'Access);
1777 pragma Assert
(Result
= 0);
1783 Result
:= mutex_unlock
(S
.L
'Access);
1784 pragma Assert
(Result
= 0);
1786 SSL
.Abort_Undefer
.all;
1789 ------------------------
1790 -- Suspend_Until_True --
1791 ------------------------
1793 procedure Suspend_Until_True
(S
: in out Suspension_Object
) is
1794 Result
: Interfaces
.C
.int
;
1797 SSL
.Abort_Defer
.all;
1799 Result
:= mutex_lock
(S
.L
'Access);
1800 pragma Assert
(Result
= 0);
1804 -- Program_Error must be raised upon calling Suspend_Until_True
1805 -- if another task is already waiting on that suspension object
1808 Result
:= mutex_unlock
(S
.L
'Access);
1809 pragma Assert
(Result
= 0);
1811 SSL
.Abort_Undefer
.all;
1813 raise Program_Error
;
1816 -- Suspend the task if the state is False. Otherwise, the task
1817 -- continues its execution, and the state of the suspension object
1818 -- is set to False (ARM D.10 par. 9).
1826 -- Loop in case pthread_cond_wait returns earlier than expected
1827 -- (e.g. in case of EINTR caused by a signal).
1829 Result
:= cond_wait
(S
.CV
'Access, S
.L
'Access);
1830 pragma Assert
(Result
= 0 or else Result
= EINTR
);
1832 exit when not S
.Waiting
;
1836 Result
:= mutex_unlock
(S
.L
'Access);
1837 pragma Assert
(Result
= 0);
1839 SSL
.Abort_Undefer
.all;
1841 end Suspend_Until_True
;
1847 function Check_Exit
(Self_ID
: Task_Id
) return Boolean is
1849 -- Check that caller is just holding Global_Task_Lock and no other locks
1851 if Self_ID
.Common
.LL
.Locks
= null then
1855 -- 2 = Global_Task_Level
1857 if Self_ID
.Common
.LL
.Locks
.Level
/= 2 then
1861 if Self_ID
.Common
.LL
.Locks
.Next
/= null then
1865 -- Check that caller is abort-deferred
1867 if Self_ID
.Deferral_Level
= 0 then
1874 --------------------
1875 -- Check_No_Locks --
1876 --------------------
1878 function Check_No_Locks
(Self_ID
: Task_Id
) return Boolean is
1880 return Self_ID
.Common
.LL
.Locks
= null;
1883 ----------------------
1884 -- Environment_Task --
1885 ----------------------
1887 function Environment_Task
return Task_Id
is
1889 return Environment_Task_Id
;
1890 end Environment_Task
;
1896 procedure Lock_RTS
is
1898 Write_Lock
(Single_RTS_Lock
'Access, Global_Lock
=> True);
1905 procedure Unlock_RTS
is
1907 Unlock
(Single_RTS_Lock
'Access, Global_Lock
=> True);
1914 function Suspend_Task
1916 Thread_Self
: Thread_Id
) return Boolean
1919 if T
.Common
.LL
.Thread
/= Thread_Self
then
1920 return thr_suspend
(T
.Common
.LL
.Thread
) = 0;
1930 function Resume_Task
1932 Thread_Self
: Thread_Id
) return Boolean
1935 if T
.Common
.LL
.Thread
/= Thread_Self
then
1936 return thr_continue
(T
.Common
.LL
.Thread
) = 0;
1942 --------------------
1943 -- Stop_All_Tasks --
1944 --------------------
1946 procedure Stop_All_Tasks
is
1955 function Stop_Task
(T
: ST
.Task_Id
) return Boolean is
1956 pragma Unreferenced
(T
);
1965 function Continue_Task
(T
: ST
.Task_Id
) return Boolean is
1966 pragma Unreferenced
(T
);
1971 end System
.Task_Primitives
.Operations
;