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
;
273 pragma Warnings
(Off
, Result
);
276 -- It is not safe to raise an exception when using ZCX and the GCC
277 -- exception handling mechanism.
279 if ZCX_By_Default
and then GCC_ZCX_Support
then
283 if Self_ID
.Deferral_Level
= 0
284 and then Self_ID
.Pending_ATC_Level
< Self_ID
.ATC_Nesting_Level
285 and then not Self_ID
.Aborting
287 Self_ID
.Aborting
:= True;
289 -- Make sure signals used for RTS internal purpose are unmasked
294 Unblocked_Signal_Mask
'Unchecked_Access,
295 Old_Set
'Unchecked_Access);
296 pragma Assert
(Result
= 0);
298 raise Standard
'Abort_Signal;
306 -- The underlying thread system sets a guard page at the
307 -- bottom of a thread stack, so nothing is needed.
309 procedure Stack_Guard
(T
: ST
.Task_Id
; On
: Boolean) is
310 pragma Unreferenced
(T
);
311 pragma Unreferenced
(On
);
320 function Get_Thread_Id
(T
: ST
.Task_Id
) return OSI
.Thread_Id
is
322 return T
.Common
.LL
.Thread
;
329 procedure Initialize
(Environment_Task
: ST
.Task_Id
) is
330 act
: aliased struct_sigaction
;
331 old_act
: aliased struct_sigaction
;
332 Tmp_Set
: aliased sigset_t
;
333 Result
: Interfaces
.C
.int
;
335 procedure Configure_Processors
;
336 -- Processors configuration
337 -- The user can specify a processor which the program should run
338 -- on to emulate a single-processor system. This can be easily
339 -- done by setting environment variable GNAT_PROCESSOR to one of
342 -- -2 : use the default configuration (run the program on all
343 -- available processors) - this is the same as having
344 -- GNAT_PROCESSOR unset
345 -- -1 : let the RTS choose one processor and run the program on
347 -- 0 .. Last_Proc : run the program on the specified processor
349 -- Last_Proc is equal to the value of the system variable
350 -- _SC_NPROCESSORS_CONF, minus one.
352 procedure Configure_Processors
is
353 Proc_Acc
: constant System
.OS_Lib
.String_Access
:=
354 System
.OS_Lib
.Getenv
("GNAT_PROCESSOR");
355 Proc
: aliased processorid_t
; -- User processor #
356 Last_Proc
: processorid_t
; -- Last processor #
359 if Proc_Acc
.all'Length /= 0 then
361 -- Environment variable is defined
363 Last_Proc
:= Num_Procs
- 1;
365 if Last_Proc
/= -1 then
366 Proc
:= processorid_t
'Value (Proc_Acc
.all);
368 if Proc
<= -2 or else Proc
> Last_Proc
then
370 -- Use the default configuration
376 -- Choose a processor
379 while Proc
< Last_Proc
loop
381 Result
:= p_online
(Proc
, PR_STATUS
);
382 exit when Result
= PR_ONLINE
;
385 pragma Assert
(Result
= PR_ONLINE
);
386 Result
:= processor_bind
(P_PID
, P_MYID
, Proc
, null);
387 pragma Assert
(Result
= 0);
390 -- Use user processor
392 Result
:= processor_bind
(P_PID
, P_MYID
, Proc
, null);
393 pragma Assert
(Result
= 0);
399 when Constraint_Error
=>
401 -- Illegal environment variable GNAT_PROCESSOR - ignored
404 end Configure_Processors
;
407 (Int
: System
.Interrupt_Management
.Interrupt_ID
) return Character;
408 pragma Import
(C
, State
, "__gnat_get_interrupt_state");
409 -- Get interrupt state. Defined in a-init.c
410 -- The input argument is the interrupt number,
411 -- and the result is one of the following:
413 Default
: constant Character := 's';
414 -- 'n' this interrupt not set by any Interrupt_State pragma
415 -- 'u' Interrupt_State pragma set state to User
416 -- 'r' Interrupt_State pragma set state to Runtime
417 -- 's' Interrupt_State pragma set state to System (use "default"
420 -- Start of processing for Initialize
423 Environment_Task_Id
:= Environment_Task
;
425 Interrupt_Management
.Initialize
;
427 -- Prepare the set of signals that should unblocked in all tasks
429 Result
:= sigemptyset
(Unblocked_Signal_Mask
'Access);
430 pragma Assert
(Result
= 0);
432 for J
in Interrupt_Management
.Interrupt_ID
loop
433 if System
.Interrupt_Management
.Keep_Unmasked
(J
) then
434 Result
:= sigaddset
(Unblocked_Signal_Mask
'Access, Signal
(J
));
435 pragma Assert
(Result
= 0);
439 if Dispatching_Policy
= 'F' then
441 Result
: Interfaces
.C
.long
;
442 Class_Info
: aliased struct_pcinfo
;
443 Secs
, Nsecs
: Interfaces
.C
.long
;
446 -- If a pragma Time_Slice is specified, takes the value in account
448 if Time_Slice_Val
> 0 then
450 -- Convert Time_Slice_Val (microseconds) to seconds/nanosecs
452 Secs
:= Interfaces
.C
.long
(Time_Slice_Val
/ 1_000_000
);
454 Interfaces
.C
.long
((Time_Slice_Val
rem 1_000_000
) * 1_000
);
456 -- Otherwise, default to no time slicing (i.e run until blocked)
463 -- Get the real time class id
465 Class_Info
.pc_clname
(1) := 'R';
466 Class_Info
.pc_clname
(2) := 'T';
467 Class_Info
.pc_clname
(3) := ASCII
.NUL
;
469 Result
:= priocntl
(PC_VERSION
, P_LWPID
, P_MYID
, PC_GETCID
,
472 -- Request the real time class
474 Prio_Param
.pc_cid
:= Class_Info
.pc_cid
;
475 Prio_Param
.rt_pri
:= pri_t
(Class_Info
.rt_maxpri
);
476 Prio_Param
.rt_tqsecs
:= Secs
;
477 Prio_Param
.rt_tqnsecs
:= Nsecs
;
481 (PC_VERSION
, P_LWPID
, P_MYID
, PC_SETPARMS
, Prio_Param
'Address);
483 Using_Real_Time_Class
:= Result
/= -1;
487 Specific
.Initialize
(Environment_Task
);
489 -- The following is done in Enter_Task, but this is too late for the
490 -- Environment Task, since we need to call Self in Check_Locks when
491 -- the run time is compiled with assertions on.
493 Specific
.Set
(Environment_Task
);
495 -- Initialize the lock used to synchronize chain of all ATCBs
497 Initialize_Lock
(Single_RTS_Lock
'Access, RTS_Lock_Level
);
499 Enter_Task
(Environment_Task
);
501 -- Install the abort-signal handler
504 (System
.Interrupt_Management
.Abort_Task_Interrupt
) /= Default
506 -- Set sa_flags to SA_NODEFER so that during the handler execution
507 -- we do not change the Signal_Mask to be masked for the Abort_Signal
508 -- This is a temporary fix to the problem that the Signal_Mask is
509 -- not restored after the exception (longjmp) from the handler.
510 -- The right fix should be made in sigsetjmp so that we save
511 -- the Signal_Set and restore it after a longjmp.
512 -- In that case, this field should be changed back to 0. ???
516 act
.sa_handler
:= Abort_Handler
'Address;
517 Result
:= sigemptyset
(Tmp_Set
'Access);
518 pragma Assert
(Result
= 0);
519 act
.sa_mask
:= Tmp_Set
;
523 (Signal
(System
.Interrupt_Management
.Abort_Task_Interrupt
),
524 act
'Unchecked_Access,
525 old_act
'Unchecked_Access);
526 pragma Assert
(Result
= 0);
529 Configure_Processors
;
532 ---------------------
533 -- Initialize_Lock --
534 ---------------------
536 -- Note: mutexes and cond_variables needed per-task basis are initialized
537 -- in Initialize_TCB and the Storage_Error is handled. Other mutexes (such
538 -- as RTS_Lock, Memory_Lock...) used in RTS is initialized before any
539 -- status change of RTS. Therefore rasing Storage_Error in the following
540 -- routines should be able to be handled safely.
542 procedure Initialize_Lock
543 (Prio
: System
.Any_Priority
;
544 L
: not null access Lock
)
546 Result
: Interfaces
.C
.int
;
549 pragma Assert
(Check_Initialize_Lock
(Lock_Ptr
(L
), PO_Level
));
551 if Priority_Ceiling_Emulation
then
555 Result
:= mutex_init
(L
.L
'Access, USYNC_THREAD
, System
.Null_Address
);
556 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
558 if Result
= ENOMEM
then
559 raise Storage_Error
with "Failed to allocate a lock";
563 procedure Initialize_Lock
564 (L
: not null access RTS_Lock
;
567 Result
: Interfaces
.C
.int
;
571 (Check_Initialize_Lock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
)), Level
));
572 Result
:= mutex_init
(L
.L
'Access, USYNC_THREAD
, System
.Null_Address
);
573 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
575 if Result
= ENOMEM
then
576 raise Storage_Error
with "Failed to allocate a lock";
584 procedure Finalize_Lock
(L
: not null access Lock
) is
585 Result
: Interfaces
.C
.int
;
587 pragma Assert
(Check_Finalize_Lock
(Lock_Ptr
(L
)));
588 Result
:= mutex_destroy
(L
.L
'Access);
589 pragma Assert
(Result
= 0);
592 procedure Finalize_Lock
(L
: not null access RTS_Lock
) is
593 Result
: Interfaces
.C
.int
;
595 pragma Assert
(Check_Finalize_Lock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
))));
596 Result
:= mutex_destroy
(L
.L
'Access);
597 pragma Assert
(Result
= 0);
605 (L
: not null access Lock
;
606 Ceiling_Violation
: out Boolean)
608 Result
: Interfaces
.C
.int
;
611 pragma Assert
(Check_Lock
(Lock_Ptr
(L
)));
613 if Priority_Ceiling_Emulation
and then Locking_Policy
= 'C' then
615 Self_Id
: constant Task_Id
:= Self
;
616 Saved_Priority
: System
.Any_Priority
;
619 if Self_Id
.Common
.LL
.Active_Priority
> L
.Ceiling
then
620 Ceiling_Violation
:= True;
624 Saved_Priority
:= Self_Id
.Common
.LL
.Active_Priority
;
626 if Self_Id
.Common
.LL
.Active_Priority
< L
.Ceiling
then
627 Set_Priority
(Self_Id
, L
.Ceiling
);
630 Result
:= mutex_lock
(L
.L
'Access);
631 pragma Assert
(Result
= 0);
632 Ceiling_Violation
:= False;
634 L
.Saved_Priority
:= Saved_Priority
;
638 Result
:= mutex_lock
(L
.L
'Access);
639 pragma Assert
(Result
= 0);
640 Ceiling_Violation
:= False;
643 pragma Assert
(Record_Lock
(Lock_Ptr
(L
)));
647 (L
: not null access RTS_Lock
;
648 Global_Lock
: Boolean := False)
650 Result
: Interfaces
.C
.int
;
652 if not Single_Lock
or else Global_Lock
then
653 pragma Assert
(Check_Lock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
))));
654 Result
:= mutex_lock
(L
.L
'Access);
655 pragma Assert
(Result
= 0);
656 pragma Assert
(Record_Lock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
))));
660 procedure Write_Lock
(T
: Task_Id
) is
661 Result
: Interfaces
.C
.int
;
663 if not Single_Lock
then
664 pragma Assert
(Check_Lock
(To_Lock_Ptr
(T
.Common
.LL
.L
'Access)));
665 Result
:= mutex_lock
(T
.Common
.LL
.L
.L
'Access);
666 pragma Assert
(Result
= 0);
667 pragma Assert
(Record_Lock
(To_Lock_Ptr
(T
.Common
.LL
.L
'Access)));
676 (L
: not null access Lock
;
677 Ceiling_Violation
: out Boolean) is
679 Write_Lock
(L
, Ceiling_Violation
);
686 procedure Unlock
(L
: not null access Lock
) is
687 Result
: Interfaces
.C
.int
;
690 pragma Assert
(Check_Unlock
(Lock_Ptr
(L
)));
692 if Priority_Ceiling_Emulation
and then Locking_Policy
= 'C' then
694 Self_Id
: constant Task_Id
:= Self
;
697 Result
:= mutex_unlock
(L
.L
'Access);
698 pragma Assert
(Result
= 0);
700 if Self_Id
.Common
.LL
.Active_Priority
> L
.Saved_Priority
then
701 Set_Priority
(Self_Id
, L
.Saved_Priority
);
705 Result
:= mutex_unlock
(L
.L
'Access);
706 pragma Assert
(Result
= 0);
711 (L
: not null access RTS_Lock
;
712 Global_Lock
: Boolean := False)
714 Result
: Interfaces
.C
.int
;
716 if not Single_Lock
or else Global_Lock
then
717 pragma Assert
(Check_Unlock
(To_Lock_Ptr
(RTS_Lock_Ptr
(L
))));
718 Result
:= mutex_unlock
(L
.L
'Access);
719 pragma Assert
(Result
= 0);
723 procedure Unlock
(T
: Task_Id
) is
724 Result
: Interfaces
.C
.int
;
726 if not Single_Lock
then
727 pragma Assert
(Check_Unlock
(To_Lock_Ptr
(T
.Common
.LL
.L
'Access)));
728 Result
:= mutex_unlock
(T
.Common
.LL
.L
.L
'Access);
729 pragma Assert
(Result
= 0);
737 -- Dynamic priority ceilings are not supported by the underlying system
739 procedure Set_Ceiling
740 (L
: not null access Lock
;
741 Prio
: System
.Any_Priority
)
743 pragma Unreferenced
(L
, Prio
);
748 -- For the time delay implementation, we need to make sure we
749 -- achieve following criteria:
751 -- 1) We have to delay at least for the amount requested.
752 -- 2) We have to give up CPU even though the actual delay does not
753 -- result in blocking.
754 -- 3) Except for restricted run-time systems that do not support
755 -- ATC or task abort, the delay must be interrupted by the
756 -- abort_task operation.
757 -- 4) The implementation has to be efficient so that the delay overhead
758 -- is relatively cheap.
759 -- (1)-(3) are Ada requirements. Even though (2) is an Annex-D
760 -- requirement we still want to provide the effect in all cases.
761 -- The reason is that users may want to use short delays to implement
762 -- their own scheduling effect in the absence of language provided
763 -- scheduling policies.
765 ---------------------
766 -- Monotonic_Clock --
767 ---------------------
769 function Monotonic_Clock
return Duration is
770 TS
: aliased timespec
;
771 Result
: Interfaces
.C
.int
;
773 Result
:= clock_gettime
(CLOCK_REALTIME
, TS
'Unchecked_Access);
774 pragma Assert
(Result
= 0);
775 return To_Duration
(TS
);
782 function RT_Resolution
return Duration is
791 procedure Yield
(Do_Yield
: Boolean := True) is
794 System
.OS_Interface
.thr_yield
;
802 function Self
return Task_Id
renames Specific
.Self
;
808 procedure Set_Priority
810 Prio
: System
.Any_Priority
;
811 Loss_Of_Inheritance
: Boolean := False)
813 pragma Unreferenced
(Loss_Of_Inheritance
);
815 Result
: Interfaces
.C
.int
;
816 pragma Unreferenced
(Result
);
818 Param
: aliased struct_pcparms
;
823 T
.Common
.Current_Priority
:= Prio
;
825 if Priority_Ceiling_Emulation
then
826 T
.Common
.LL
.Active_Priority
:= Prio
;
829 if Using_Real_Time_Class
then
830 Param
.pc_cid
:= Prio_Param
.pc_cid
;
831 Param
.rt_pri
:= pri_t
(Prio
);
832 Param
.rt_tqsecs
:= Prio_Param
.rt_tqsecs
;
833 Param
.rt_tqnsecs
:= Prio_Param
.rt_tqnsecs
;
835 Result
:= Interfaces
.C
.int
(
836 priocntl
(PC_VERSION
, P_LWPID
, T
.Common
.LL
.LWP
, PC_SETPARMS
,
840 if T
.Common
.Task_Info
/= null
841 and then not T
.Common
.Task_Info
.Bound_To_LWP
843 -- The task is not bound to a LWP, so use thr_setprio
846 thr_setprio
(T
.Common
.LL
.Thread
, Interfaces
.C
.int
(Prio
));
849 -- The task is bound to a LWP, use priocntl
861 function Get_Priority
(T
: Task_Id
) return System
.Any_Priority
is
863 return T
.Common
.Current_Priority
;
870 procedure Enter_Task
(Self_ID
: Task_Id
) is
871 Result
: Interfaces
.C
.int
;
872 Proc
: processorid_t
; -- User processor #
873 Last_Proc
: processorid_t
; -- Last processor #
875 use System
.Task_Info
;
877 Self_ID
.Common
.LL
.Thread
:= thr_self
;
879 Self_ID
.Common
.LL
.LWP
:= lwp_self
;
881 if Self_ID
.Common
.Task_Info
/= null then
882 if Self_ID
.Common
.Task_Info
.New_LWP
883 and then Self_ID
.Common
.Task_Info
.CPU
/= CPU_UNCHANGED
885 Last_Proc
:= Num_Procs
- 1;
887 if Self_ID
.Common
.Task_Info
.CPU
= ANY_CPU
then
890 while Proc
< Last_Proc
loop
891 Result
:= p_online
(Proc
, PR_STATUS
);
892 exit when Result
= PR_ONLINE
;
896 Result
:= processor_bind
(P_LWPID
, P_MYID
, Proc
, null);
897 pragma Assert
(Result
= 0);
900 -- Use specified processor
902 if Self_ID
.Common
.Task_Info
.CPU
< 0
903 or else Self_ID
.Common
.Task_Info
.CPU
> Last_Proc
905 raise Invalid_CPU_Number
;
910 (P_LWPID
, P_MYID
, Self_ID
.Common
.Task_Info
.CPU
, null);
911 pragma Assert
(Result
= 0);
916 Specific
.Set
(Self_ID
);
918 -- We need the above code even if we do direct fetch of Task_Id in Self
919 -- for the main task on Sun, x86 Solaris and for gcc 2.7.2.
923 for J
in Known_Tasks
'Range loop
924 if Known_Tasks
(J
) = null then
925 Known_Tasks
(J
) := Self_ID
;
926 Self_ID
.Known_Tasks_Index
:= J
;
938 function New_ATCB
(Entry_Num
: Task_Entry_Index
) return Task_Id
is
940 return new Ada_Task_Control_Block
(Entry_Num
);
947 function Is_Valid_Task
return Boolean renames Specific
.Is_Valid_Task
;
949 -----------------------------
950 -- Register_Foreign_Thread --
951 -----------------------------
953 function Register_Foreign_Thread
return Task_Id
is
955 if Is_Valid_Task
then
958 return Register_Foreign_Thread
(thr_self
);
960 end Register_Foreign_Thread
;
966 procedure Initialize_TCB
(Self_ID
: Task_Id
; Succeeded
: out Boolean) is
967 Result
: Interfaces
.C
.int
:= 0;
970 -- Give the task a unique serial number
972 Self_ID
.Serial_Number
:= Next_Serial_Number
;
973 Next_Serial_Number
:= Next_Serial_Number
+ 1;
974 pragma Assert
(Next_Serial_Number
/= 0);
976 Self_ID
.Common
.LL
.Thread
:= To_thread_t
(-1);
978 if not Single_Lock
then
981 (Self_ID
.Common
.LL
.L
.L
'Access, USYNC_THREAD
, System
.Null_Address
);
982 Self_ID
.Common
.LL
.L
.Level
:=
983 Private_Task_Serial_Number
(Self_ID
.Serial_Number
);
984 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
988 Result
:= cond_init
(Self_ID
.Common
.LL
.CV
'Access, USYNC_THREAD
, 0);
989 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
995 if not Single_Lock
then
996 Result
:= mutex_destroy
(Self_ID
.Common
.LL
.L
.L
'Access);
997 pragma Assert
(Result
= 0);
1008 procedure Create_Task
1010 Wrapper
: System
.Address
;
1011 Stack_Size
: System
.Parameters
.Size_Type
;
1012 Priority
: System
.Any_Priority
;
1013 Succeeded
: out Boolean)
1015 pragma Unreferenced
(Priority
);
1017 Result
: Interfaces
.C
.int
;
1018 Adjusted_Stack_Size
: Interfaces
.C
.size_t
;
1019 Opts
: Interfaces
.C
.int
:= THR_DETACHED
;
1021 Page_Size
: constant System
.Parameters
.Size_Type
:= 4096;
1022 -- This constant is for reserving extra space at the
1023 -- end of the stack, which can be used by the stack
1024 -- checking as guard page. The idea is that we need
1025 -- to have at least Stack_Size bytes available for
1028 use System
.Task_Info
;
1031 Adjusted_Stack_Size
:= Interfaces
.C
.size_t
(Stack_Size
+ Page_Size
);
1033 -- Since the initial signal mask of a thread is inherited from the
1034 -- creator, and the Environment task has all its signals masked, we
1035 -- do not need to manipulate caller's signal mask at this point.
1036 -- All tasks in RTS will have All_Tasks_Mask initially.
1038 if T
.Common
.Task_Info
/= null then
1039 if T
.Common
.Task_Info
.New_LWP
then
1040 Opts
:= Opts
+ THR_NEW_LWP
;
1043 if T
.Common
.Task_Info
.Bound_To_LWP
then
1044 Opts
:= Opts
+ THR_BOUND
;
1048 Opts
:= THR_DETACHED
+ THR_BOUND
;
1053 (System
.Null_Address
,
1054 Adjusted_Stack_Size
,
1055 Thread_Body_Access
(Wrapper
),
1058 T
.Common
.LL
.Thread
'Access);
1060 Succeeded
:= Result
= 0;
1063 or else Result
= ENOMEM
1064 or else Result
= EAGAIN
);
1071 procedure Finalize_TCB
(T
: Task_Id
) is
1072 Result
: Interfaces
.C
.int
;
1074 Is_Self
: constant Boolean := T
= Self
;
1076 procedure Free
is new
1077 Ada
.Unchecked_Deallocation
(Ada_Task_Control_Block
, Task_Id
);
1080 T
.Common
.LL
.Thread
:= To_thread_t
(0);
1082 if not Single_Lock
then
1083 Result
:= mutex_destroy
(T
.Common
.LL
.L
.L
'Access);
1084 pragma Assert
(Result
= 0);
1087 Result
:= cond_destroy
(T
.Common
.LL
.CV
'Access);
1088 pragma Assert
(Result
= 0);
1090 if T
.Known_Tasks_Index
/= -1 then
1091 Known_Tasks
(T
.Known_Tasks_Index
) := null;
1097 Specific
.Set
(null);
1105 -- This procedure must be called with abort deferred. It can no longer
1106 -- call Self or access the current task's ATCB, since the ATCB has been
1109 procedure Exit_Task
is
1111 Specific
.Set
(null);
1118 procedure Abort_Task
(T
: Task_Id
) is
1119 Result
: Interfaces
.C
.int
;
1121 pragma Assert
(T
/= Self
);
1124 (T
.Common
.LL
.Thread
,
1125 Signal
(System
.Interrupt_Management
.Abort_Task_Interrupt
));
1126 pragma Assert
(Result
= 0);
1135 Reason
: Task_States
)
1137 Result
: Interfaces
.C
.int
;
1140 pragma Assert
(Check_Sleep
(Reason
));
1145 (Self_ID
.Common
.LL
.CV
'Access, Single_RTS_Lock
.L
'Access);
1149 (Self_ID
.Common
.LL
.CV
'Access, Self_ID
.Common
.LL
.L
.L
'Access);
1153 (Record_Wakeup
(To_Lock_Ptr
(Self_ID
.Common
.LL
.L
'Access), Reason
));
1154 pragma Assert
(Result
= 0 or else Result
= EINTR
);
1157 -- Note that we are relying heaviliy here on GNAT represting Calendar.Time,
1158 -- System.Real_Time.Time, Duration, System.Real_Time.Time_Span in the same
1159 -- way, i.e., as a 64-bit count of nanoseconds.
1161 -- This allows us to always pass the timeout value as a Duration
1164 -- We are taking liberties here with the semantics of the delays. That is,
1165 -- we make no distinction between delays on the Calendar clock and delays
1166 -- on the Real_Time clock. That is technically incorrect, if the Calendar
1167 -- clock happens to be reset or adjusted. To solve this defect will require
1168 -- modification to the compiler interface, so that it can pass through more
1169 -- information, to tell us here which clock to use!
1171 -- cond_timedwait will return if any of the following happens:
1172 -- 1) some other task did cond_signal on this condition variable
1173 -- In this case, the return value is 0
1174 -- 2) the call just returned, for no good reason
1175 -- This is called a "spurious wakeup".
1176 -- In this case, the return value may also be 0.
1177 -- 3) the time delay expires
1178 -- In this case, the return value is ETIME
1179 -- 4) this task received a signal, which was handled by some
1180 -- handler procedure, and now the thread is resuming execution
1181 -- UNIX calls this an "interrupted" system call.
1182 -- In this case, the return value is EINTR
1184 -- If the cond_timedwait returns 0 or EINTR, it is still possible that the
1185 -- time has actually expired, and by chance a signal or cond_signal
1186 -- occurred at around the same time.
1188 -- We have also observed that on some OS's the value ETIME will be
1189 -- returned, but the clock will show that the full delay has not yet
1192 -- For these reasons, we need to check the clock after return from
1193 -- cond_timedwait. If the time has expired, we will set Timedout = True.
1195 -- This check might be omitted for systems on which the cond_timedwait()
1196 -- never returns early or wakes up spuriously.
1198 -- Annex D requires that completion of a delay cause the task to go to the
1199 -- end of its priority queue, regardless of whether the task actually was
1200 -- suspended by the delay. Since cond_timedwait does not do this on
1201 -- Solaris, we add a call to thr_yield at the end. We might do this at the
1202 -- beginning, instead, but then the round-robin effect would not be the
1203 -- same; the delayed task would be ahead of other tasks of the same
1204 -- priority that awoke while it was sleeping.
1206 -- For Timed_Sleep, we are expecting possible cond_signals to indicate
1207 -- other events (e.g., completion of a RV or completion of the abortable
1208 -- part of an async. select), we want to always return if interrupted. The
1209 -- caller will be responsible for checking the task state to see whether
1210 -- the wakeup was spurious, and to go back to sleep again in that case. We
1211 -- don't need to check for pending abort or priority change on the way in
1212 -- our out; that is the caller's responsibility.
1214 -- For Timed_Delay, we are not expecting any cond_signals or other
1215 -- interruptions, except for priority changes and aborts. Therefore, we
1216 -- don't want to return unless the delay has actually expired, or the call
1217 -- has been aborted. In this case, since we want to implement the entire
1218 -- delay statement semantics, we do need to check for pending abort and
1219 -- priority changes. We can quietly handle priority changes inside the
1220 -- procedure, since there is no entry-queue reordering involved.
1226 procedure Timed_Sleep
1229 Mode
: ST
.Delay_Modes
;
1230 Reason
: System
.Tasking
.Task_States
;
1231 Timedout
: out Boolean;
1232 Yielded
: out Boolean)
1234 Base_Time
: constant Duration := Monotonic_Clock
;
1235 Check_Time
: Duration := Base_Time
;
1236 Abs_Time
: Duration;
1237 Request
: aliased timespec
;
1238 Result
: Interfaces
.C
.int
;
1241 pragma Assert
(Check_Sleep
(Reason
));
1245 if Mode
= Relative
then
1246 Abs_Time
:= Duration'Min (Time
, Max_Sensible_Delay
) + Check_Time
;
1248 Abs_Time
:= Duration'Min (Check_Time
+ Max_Sensible_Delay
, Time
);
1251 if Abs_Time
> Check_Time
then
1252 Request
:= To_Timespec
(Abs_Time
);
1255 exit when Self_ID
.Pending_ATC_Level
< Self_ID
.ATC_Nesting_Level
;
1260 (Self_ID
.Common
.LL
.CV
'Access,
1261 Single_RTS_Lock
.L
'Access, Request
'Access);
1265 (Self_ID
.Common
.LL
.CV
'Access,
1266 Self_ID
.Common
.LL
.L
.L
'Access, Request
'Access);
1271 Check_Time
:= Monotonic_Clock
;
1272 exit when Abs_Time
<= Check_Time
or else Check_Time
< Base_Time
;
1274 if Result
= 0 or Result
= EINTR
then
1276 -- Somebody may have called Wakeup for us
1282 pragma Assert
(Result
= ETIME
);
1287 (Record_Wakeup
(To_Lock_Ptr
(Self_ID
.Common
.LL
.L
'Access), Reason
));
1294 procedure Timed_Delay
1297 Mode
: ST
.Delay_Modes
)
1299 Base_Time
: constant Duration := Monotonic_Clock
;
1300 Check_Time
: Duration := Base_Time
;
1301 Abs_Time
: Duration;
1302 Request
: aliased timespec
;
1303 Result
: Interfaces
.C
.int
;
1304 Yielded
: Boolean := False;
1311 Write_Lock
(Self_ID
);
1313 if Mode
= Relative
then
1314 Abs_Time
:= Time
+ Check_Time
;
1316 Abs_Time
:= Duration'Min (Check_Time
+ Max_Sensible_Delay
, Time
);
1319 if Abs_Time
> Check_Time
then
1320 Request
:= To_Timespec
(Abs_Time
);
1321 Self_ID
.Common
.State
:= Delay_Sleep
;
1323 pragma Assert
(Check_Sleep
(Delay_Sleep
));
1326 exit when Self_ID
.Pending_ATC_Level
< Self_ID
.ATC_Nesting_Level
;
1331 (Self_ID
.Common
.LL
.CV
'Access,
1332 Single_RTS_Lock
.L
'Access,
1337 (Self_ID
.Common
.LL
.CV
'Access,
1338 Self_ID
.Common
.LL
.L
.L
'Access,
1344 Check_Time
:= Monotonic_Clock
;
1345 exit when Abs_Time
<= Check_Time
or else Check_Time
< Base_Time
;
1349 Result
= ETIME
or else
1355 (To_Lock_Ptr
(Self_ID
.Common
.LL
.L
'Access), Delay_Sleep
));
1357 Self_ID
.Common
.State
:= Runnable
;
1377 Reason
: Task_States
)
1379 Result
: Interfaces
.C
.int
;
1381 pragma Assert
(Check_Wakeup
(T
, Reason
));
1382 Result
:= cond_signal
(T
.Common
.LL
.CV
'Access);
1383 pragma Assert
(Result
= 0);
1386 ---------------------------
1387 -- Check_Initialize_Lock --
1388 ---------------------------
1390 -- The following code is intended to check some of the invariant assertions
1391 -- related to lock usage, on which we depend.
1393 function Check_Initialize_Lock
1395 Level
: Lock_Level
) return Boolean
1397 Self_ID
: constant Task_Id
:= Self
;
1400 -- Check that caller is abort-deferred
1402 if Self_ID
.Deferral_Level
= 0 then
1406 -- Check that the lock is not yet initialized
1408 if L
.Level
/= 0 then
1412 L
.Level
:= Lock_Level
'Pos (Level
) + 1;
1414 end Check_Initialize_Lock
;
1420 function Check_Lock
(L
: Lock_Ptr
) return Boolean is
1421 Self_ID
: constant Task_Id
:= Self
;
1425 -- Check that the argument is not null
1431 -- Check that L is not frozen
1437 -- Check that caller is abort-deferred
1439 if Self_ID
.Deferral_Level
= 0 then
1443 -- Check that caller is not holding this lock already
1445 if L
.Owner
= To_Owner_ID
(To_Address
(Self_ID
)) then
1453 -- Check that TCB lock order rules are satisfied
1455 P
:= Self_ID
.Common
.LL
.Locks
;
1457 if P
.Level
>= L
.Level
1458 and then (P
.Level
> 2 or else L
.Level
> 2)
1471 function Record_Lock
(L
: Lock_Ptr
) return Boolean is
1472 Self_ID
: constant Task_Id
:= Self
;
1476 Lock_Count
:= Lock_Count
+ 1;
1478 -- There should be no owner for this lock at this point
1480 if L
.Owner
/= null then
1486 L
.Owner
:= To_Owner_ID
(To_Address
(Self_ID
));
1492 -- Check that TCB lock order rules are satisfied
1494 P
:= Self_ID
.Common
.LL
.Locks
;
1500 Self_ID
.Common
.LL
.Locking
:= null;
1501 Self_ID
.Common
.LL
.Locks
:= L
;
1509 function Check_Sleep
(Reason
: Task_States
) return Boolean is
1510 pragma Unreferenced
(Reason
);
1512 Self_ID
: constant Task_Id
:= Self
;
1516 -- Check that caller is abort-deferred
1518 if Self_ID
.Deferral_Level
= 0 then
1526 -- Check that caller is holding own lock, on top of list
1528 if Self_ID
.Common
.LL
.Locks
/=
1529 To_Lock_Ptr
(Self_ID
.Common
.LL
.L
'Access)
1534 -- Check that TCB lock order rules are satisfied
1536 if Self_ID
.Common
.LL
.Locks
.Next
/= null then
1540 Self_ID
.Common
.LL
.L
.Owner
:= null;
1541 P
:= Self_ID
.Common
.LL
.Locks
;
1542 Self_ID
.Common
.LL
.Locks
:= Self_ID
.Common
.LL
.Locks
.Next
;
1551 function Record_Wakeup
1553 Reason
: Task_States
) return Boolean
1555 pragma Unreferenced
(Reason
);
1557 Self_ID
: constant Task_Id
:= Self
;
1563 L
.Owner
:= To_Owner_ID
(To_Address
(Self_ID
));
1569 -- Check that TCB lock order rules are satisfied
1571 P
:= Self_ID
.Common
.LL
.Locks
;
1577 Self_ID
.Common
.LL
.Locking
:= null;
1578 Self_ID
.Common
.LL
.Locks
:= L
;
1586 function Check_Wakeup
1588 Reason
: Task_States
) return Boolean
1590 Self_ID
: constant Task_Id
:= Self
;
1593 -- Is caller holding T's lock?
1595 if T
.Common
.LL
.L
.Owner
/= To_Owner_ID
(To_Address
(Self_ID
)) then
1599 -- Are reasons for wakeup and sleep consistent?
1601 if T
.Common
.State
/= Reason
then
1612 function Check_Unlock
(L
: Lock_Ptr
) return Boolean is
1613 Self_ID
: constant Task_Id
:= Self
;
1617 Unlock_Count
:= Unlock_Count
+ 1;
1623 if L
.Buddy
/= null then
1627 -- Magic constant 4???
1630 Check_Count
:= Unlock_Count
;
1633 -- Magic constant 1000???
1635 if Unlock_Count
- Check_Count
> 1000 then
1636 Check_Count
:= Unlock_Count
;
1639 -- Check that caller is abort-deferred
1641 if Self_ID
.Deferral_Level
= 0 then
1645 -- Check that caller is holding this lock, on top of list
1647 if Self_ID
.Common
.LL
.Locks
/= L
then
1651 -- Record there is no owner now
1654 P
:= Self_ID
.Common
.LL
.Locks
;
1655 Self_ID
.Common
.LL
.Locks
:= Self_ID
.Common
.LL
.Locks
.Next
;
1660 --------------------
1661 -- Check_Finalize --
1662 --------------------
1664 function Check_Finalize_Lock
(L
: Lock_Ptr
) return Boolean is
1665 Self_ID
: constant Task_Id
:= Self
;
1668 -- Check that caller is abort-deferred
1670 if Self_ID
.Deferral_Level
= 0 then
1674 -- Check that no one is holding this lock
1676 if L
.Owner
/= null then
1682 end Check_Finalize_Lock
;
1688 procedure Initialize
(S
: in out Suspension_Object
) is
1689 Result
: Interfaces
.C
.int
;
1692 -- Initialize internal state (always to zero (RM D.10(6)))
1697 -- Initialize internal mutex
1699 Result
:= mutex_init
(S
.L
'Access, USYNC_THREAD
, System
.Null_Address
);
1700 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
1702 if Result
= ENOMEM
then
1703 raise Storage_Error
with "Failed to allocate a lock";
1706 -- Initialize internal condition variable
1708 Result
:= cond_init
(S
.CV
'Access, USYNC_THREAD
, 0);
1709 pragma Assert
(Result
= 0 or else Result
= ENOMEM
);
1712 Result
:= mutex_destroy
(S
.L
'Access);
1713 pragma Assert
(Result
= 0);
1715 if Result
= ENOMEM
then
1716 raise Storage_Error
;
1725 procedure Finalize
(S
: in out Suspension_Object
) is
1726 Result
: Interfaces
.C
.int
;
1729 -- Destroy internal mutex
1731 Result
:= mutex_destroy
(S
.L
'Access);
1732 pragma Assert
(Result
= 0);
1734 -- Destroy internal condition variable
1736 Result
:= cond_destroy
(S
.CV
'Access);
1737 pragma Assert
(Result
= 0);
1744 function Current_State
(S
: Suspension_Object
) return Boolean is
1746 -- We do not want to use lock on this read operation. State is marked
1747 -- as Atomic so that we ensure that the value retrieved is correct.
1756 procedure Set_False
(S
: in out Suspension_Object
) is
1757 Result
: Interfaces
.C
.int
;
1760 SSL
.Abort_Defer
.all;
1762 Result
:= mutex_lock
(S
.L
'Access);
1763 pragma Assert
(Result
= 0);
1767 Result
:= mutex_unlock
(S
.L
'Access);
1768 pragma Assert
(Result
= 0);
1770 SSL
.Abort_Undefer
.all;
1777 procedure Set_True
(S
: in out Suspension_Object
) is
1778 Result
: Interfaces
.C
.int
;
1781 SSL
.Abort_Defer
.all;
1783 Result
:= mutex_lock
(S
.L
'Access);
1784 pragma Assert
(Result
= 0);
1786 -- If there is already a task waiting on this suspension object then
1787 -- we resume it, leaving the state of the suspension object to False,
1788 -- as it is specified in ARM D.10 par. 9. Otherwise, it just leaves
1789 -- the state to True.
1795 Result
:= cond_signal
(S
.CV
'Access);
1796 pragma Assert
(Result
= 0);
1802 Result
:= mutex_unlock
(S
.L
'Access);
1803 pragma Assert
(Result
= 0);
1805 SSL
.Abort_Undefer
.all;
1808 ------------------------
1809 -- Suspend_Until_True --
1810 ------------------------
1812 procedure Suspend_Until_True
(S
: in out Suspension_Object
) is
1813 Result
: Interfaces
.C
.int
;
1816 SSL
.Abort_Defer
.all;
1818 Result
:= mutex_lock
(S
.L
'Access);
1819 pragma Assert
(Result
= 0);
1823 -- Program_Error must be raised upon calling Suspend_Until_True
1824 -- if another task is already waiting on that suspension object
1827 Result
:= mutex_unlock
(S
.L
'Access);
1828 pragma Assert
(Result
= 0);
1830 SSL
.Abort_Undefer
.all;
1832 raise Program_Error
;
1835 -- Suspend the task if the state is False. Otherwise, the task
1836 -- continues its execution, and the state of the suspension object
1837 -- is set to False (ARM D.10 par. 9).
1843 Result
:= cond_wait
(S
.CV
'Access, S
.L
'Access);
1846 Result
:= mutex_unlock
(S
.L
'Access);
1847 pragma Assert
(Result
= 0);
1849 SSL
.Abort_Undefer
.all;
1851 end Suspend_Until_True
;
1857 function Check_Exit
(Self_ID
: Task_Id
) return Boolean is
1859 -- Check that caller is just holding Global_Task_Lock and no other locks
1861 if Self_ID
.Common
.LL
.Locks
= null then
1865 -- 2 = Global_Task_Level
1867 if Self_ID
.Common
.LL
.Locks
.Level
/= 2 then
1871 if Self_ID
.Common
.LL
.Locks
.Next
/= null then
1875 -- Check that caller is abort-deferred
1877 if Self_ID
.Deferral_Level
= 0 then
1884 --------------------
1885 -- Check_No_Locks --
1886 --------------------
1888 function Check_No_Locks
(Self_ID
: Task_Id
) return Boolean is
1890 return Self_ID
.Common
.LL
.Locks
= null;
1893 ----------------------
1894 -- Environment_Task --
1895 ----------------------
1897 function Environment_Task
return Task_Id
is
1899 return Environment_Task_Id
;
1900 end Environment_Task
;
1906 procedure Lock_RTS
is
1908 Write_Lock
(Single_RTS_Lock
'Access, Global_Lock
=> True);
1915 procedure Unlock_RTS
is
1917 Unlock
(Single_RTS_Lock
'Access, Global_Lock
=> True);
1924 function Suspend_Task
1926 Thread_Self
: Thread_Id
) return Boolean
1929 if T
.Common
.LL
.Thread
/= Thread_Self
then
1930 return thr_suspend
(T
.Common
.LL
.Thread
) = 0;
1940 function Resume_Task
1942 Thread_Self
: Thread_Id
) return Boolean
1945 if T
.Common
.LL
.Thread
/= Thread_Self
then
1946 return thr_continue
(T
.Common
.LL
.Thread
) = 0;
1952 --------------------
1953 -- Stop_All_Tasks --
1954 --------------------
1956 procedure Stop_All_Tasks
is
1965 function Stop_Task
(T
: ST
.Task_Id
) return Boolean is
1966 pragma Unreferenced
(T
);
1975 function Continue_Task
(T
: ST
.Task_Id
) return Boolean is
1976 pragma Unreferenced
(T
);
1981 end System
.Task_Primitives
.Operations
;