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-2011, 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 OpenVMS/Alpha 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_Conversion;
45 with System.Tasking.Debug;
46 with System.OS_Primitives;
47 with System.Soft_Links;
50 package body System.Task_Primitives.Operations is
52 use System.Tasking.Debug;
55 use System.OS_Interface;
56 use System.Parameters;
57 use System.OS_Primitives;
58 use type System.OS_Primitives.OS_Time;
60 package SSL renames System.Soft_Links;
66 -- The followings are logically constants, but need to be initialized
69 Single_RTS_Lock : aliased RTS_Lock;
70 -- This is a lock to allow only one thread of control in the RTS at
71 -- a time; it is used to execute in mutual exclusion from all other tasks.
72 -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List
74 ATCB_Key : aliased pthread_key_t;
75 -- Key used to find the Ada Task_Id associated with a thread
77 Environment_Task_Id : Task_Id;
78 -- A variable to hold Task_Id for the environment task
80 Time_Slice_Val : Integer;
81 pragma Import (C, Time_Slice_Val, "__gl_time_slice_val");
83 Dispatching_Policy : Character;
84 pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
86 Foreign_Task_Elaborated : aliased Boolean := True;
87 -- Used to identified fake tasks (i.e., non-Ada Threads)
95 procedure Initialize (Environment_Task : Task_Id);
96 pragma Inline (Initialize);
97 -- Initialize various data needed by this package
99 function Is_Valid_Task return Boolean;
100 pragma Inline (Is_Valid_Task);
101 -- Does executing thread have a TCB?
103 procedure Set (Self_Id : Task_Id);
105 -- Set the self id for the current task
107 function Self return Task_Id;
108 pragma Inline (Self);
109 -- Return a pointer to the Ada Task Control Block of the calling task
113 package body Specific is separate;
114 -- The body of this package is target specific
116 ----------------------------------
117 -- ATCB allocation/deallocation --
118 ----------------------------------
120 package body ATCB_Allocation is separate;
121 -- The body of this package is shared across several targets
123 ---------------------------------
124 -- Support for foreign threads --
125 ---------------------------------
127 function Register_Foreign_Thread (Thread : Thread_Id) return Task_Id;
128 -- Allocate and Initialize a new ATCB for the current Thread
130 function Register_Foreign_Thread
131 (Thread : Thread_Id) return Task_Id is separate;
133 -----------------------
134 -- Local Subprograms --
135 -----------------------
137 function To_Task_Id is
138 new Ada.Unchecked_Conversion
139 (System.Task_Primitives.Task_Address, Task_Id);
141 function To_Address is
142 new Ada.Unchecked_Conversion
143 (Task_Id, System.Task_Primitives.Task_Address);
145 procedure Timer_Sleep_AST (ID : Address);
146 pragma Convention (C, Timer_Sleep_AST);
147 -- Signal the condition variable when AST fires
149 procedure Timer_Sleep_AST (ID : Address) is
150 Result : Interfaces.C.int;
151 pragma Warnings (Off, Result);
152 Self_ID : constant Task_Id := To_Task_Id (ID);
154 Self_ID.Common.LL.AST_Pending := False;
155 Result := pthread_cond_signal_int_np (Self_ID.Common.LL.CV'Access);
156 pragma Assert (Result = 0);
163 -- The underlying thread system sets a guard page at the bottom of a thread
164 -- stack, so nothing is needed.
165 -- ??? Check the comment above
167 procedure Stack_Guard (T : ST.Task_Id; On : Boolean) is
168 pragma Unreferenced (T);
169 pragma Unreferenced (On);
178 function Get_Thread_Id (T : ST.Task_Id) return OSI.Thread_Id is
180 return T.Common.LL.Thread;
187 function Self return Task_Id renames Specific.Self;
189 ---------------------
190 -- Initialize_Lock --
191 ---------------------
193 -- Note: mutexes and cond_variables needed per-task basis are initialized
194 -- in Initialize_TCB and the Storage_Error is handled. Other mutexes (such
195 -- as RTS_Lock, Memory_Lock...) used in RTS is initialized before any
196 -- status change of RTS. Therefore raising Storage_Error in the following
197 -- routines should be able to be handled safely.
199 procedure Initialize_Lock
200 (Prio : System.Any_Priority;
201 L : not null access Lock)
203 Attributes : aliased pthread_mutexattr_t;
204 Result : Interfaces.C.int;
207 Result := pthread_mutexattr_init (Attributes'Access);
208 pragma Assert (Result = 0 or else Result = ENOMEM);
210 if Result = ENOMEM then
215 L.Prio := Interfaces.C.int (Prio);
217 Result := pthread_mutex_init (L.L'Access, Attributes'Access);
218 pragma Assert (Result = 0 or else Result = ENOMEM);
220 if Result = ENOMEM then
224 Result := pthread_mutexattr_destroy (Attributes'Access);
225 pragma Assert (Result = 0);
228 procedure Initialize_Lock
229 (L : not null access RTS_Lock;
232 pragma Unreferenced (Level);
234 Attributes : aliased pthread_mutexattr_t;
235 Result : Interfaces.C.int;
238 Result := pthread_mutexattr_init (Attributes'Access);
239 pragma Assert (Result = 0 or else Result = ENOMEM);
241 if Result = ENOMEM then
245 -- Don't use, see comment in s-osinte.ads about ERRORCHECK mutexes???
246 -- Result := pthread_mutexattr_settype_np
247 -- (Attributes'Access, PTHREAD_MUTEX_ERRORCHECK_NP);
248 -- pragma Assert (Result = 0);
250 -- Result := pthread_mutexattr_setprotocol
251 -- (Attributes'Access, PTHREAD_PRIO_PROTECT);
252 -- pragma Assert (Result = 0);
254 -- Result := pthread_mutexattr_setprioceiling
255 -- (Attributes'Access, Interfaces.C.int (System.Any_Priority'Last));
256 -- pragma Assert (Result = 0);
258 Result := pthread_mutex_init (L, Attributes'Access);
260 pragma Assert (Result = 0 or else Result = ENOMEM);
262 if Result = ENOMEM then
266 Result := pthread_mutexattr_destroy (Attributes'Access);
267 pragma Assert (Result = 0);
274 procedure Finalize_Lock (L : not null access Lock) is
275 Result : Interfaces.C.int;
277 Result := pthread_mutex_destroy (L.L'Access);
278 pragma Assert (Result = 0);
281 procedure Finalize_Lock (L : not null access RTS_Lock) is
282 Result : Interfaces.C.int;
284 Result := pthread_mutex_destroy (L);
285 pragma Assert (Result = 0);
293 (L : not null access Lock;
294 Ceiling_Violation : out Boolean)
296 Self_ID : constant Task_Id := Self;
297 All_Tasks_Link : constant Task_Id := Self.Common.All_Tasks_Link;
298 Current_Prio : System.Any_Priority;
299 Result : Interfaces.C.int;
302 Current_Prio := Get_Priority (Self_ID);
304 -- If there is no other tasks, no need to check priorities
306 if All_Tasks_Link /= Null_Task
307 and then L.Prio < Interfaces.C.int (Current_Prio)
309 Ceiling_Violation := True;
313 Result := pthread_mutex_lock (L.L'Access);
314 pragma Assert (Result = 0);
316 Ceiling_Violation := False;
317 -- Why is this commented out ???
318 -- L.Prio_Save := Interfaces.C.int (Current_Prio);
319 -- Set_Priority (Self_ID, System.Any_Priority (L.Prio));
323 (L : not null access RTS_Lock;
324 Global_Lock : Boolean := False)
326 Result : Interfaces.C.int;
328 if not Single_Lock or else Global_Lock then
329 Result := pthread_mutex_lock (L);
330 pragma Assert (Result = 0);
334 procedure Write_Lock (T : Task_Id) is
335 Result : Interfaces.C.int;
337 if not Single_Lock then
338 Result := pthread_mutex_lock (T.Common.LL.L'Access);
339 pragma Assert (Result = 0);
348 (L : not null access Lock;
349 Ceiling_Violation : out Boolean)
352 Write_Lock (L, Ceiling_Violation);
359 procedure Unlock (L : not null access Lock) is
360 Result : Interfaces.C.int;
362 Result := pthread_mutex_unlock (L.L'Access);
363 pragma Assert (Result = 0);
367 (L : not null access RTS_Lock;
368 Global_Lock : Boolean := False)
370 Result : Interfaces.C.int;
372 if not Single_Lock or else Global_Lock then
373 Result := pthread_mutex_unlock (L);
374 pragma Assert (Result = 0);
378 procedure Unlock (T : Task_Id) is
379 Result : Interfaces.C.int;
381 if not Single_Lock then
382 Result := pthread_mutex_unlock (T.Common.LL.L'Access);
383 pragma Assert (Result = 0);
391 -- Dynamic priority ceilings are not supported by the underlying system
393 procedure Set_Ceiling
394 (L : not null access Lock;
395 Prio : System.Any_Priority)
397 pragma Unreferenced (L, Prio);
408 Reason : System.Tasking.Task_States)
410 pragma Unreferenced (Reason);
411 Result : Interfaces.C.int;
416 (cond => Self_ID.Common.LL.CV'Access,
417 mutex => (if Single_Lock
418 then Single_RTS_Lock'Access
419 else Self_ID.Common.LL.L'Access));
421 -- EINTR is not considered a failure
423 pragma Assert (Result = 0 or else Result = EINTR);
425 if Self_ID.Deferral_Level = 0
426 and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level
429 raise Standard'Abort_Signal;
437 procedure Timed_Sleep
440 Mode : ST.Delay_Modes;
441 Reason : System.Tasking.Task_States;
442 Timedout : out Boolean;
443 Yielded : out Boolean)
445 pragma Unreferenced (Reason);
447 Sleep_Time : OS_Time;
448 Result : Interfaces.C.int;
449 Status : Cond_Value_Type;
451 -- The body below requires more comments ???
457 Sleep_Time := To_OS_Time (Time, Mode);
459 if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level then
463 Self_ID.Common.LL.AST_Pending := True;
466 (Status, 0, Sleep_Time,
467 Timer_Sleep_AST'Access, To_Address (Self_ID), 0);
469 if (Status and 1) /= 1 then
476 (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access);
477 pragma Assert (Result = 0);
482 (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access);
483 pragma Assert (Result = 0);
488 if not Self_ID.Common.LL.AST_Pending then
491 Sys_Cantim (Status, To_Address (Self_ID), 0);
492 pragma Assert ((Status and 1) = 1);
500 procedure Timed_Delay
503 Mode : ST.Delay_Modes)
505 Sleep_Time : OS_Time;
506 Result : Interfaces.C.int;
507 Status : Cond_Value_Type;
508 Yielded : Boolean := False;
515 -- More comments required in body below ???
517 Write_Lock (Self_ID);
519 if Time /= 0.0 or else Mode /= Relative then
520 Sleep_Time := To_OS_Time (Time, Mode);
522 if Mode = Relative or else OS_Clock <= Sleep_Time then
523 Self_ID.Common.State := Delay_Sleep;
524 Self_ID.Common.LL.AST_Pending := True;
527 (Status, 0, Sleep_Time,
528 Timer_Sleep_AST'Access, To_Address (Self_ID), 0);
530 -- Comment following test
532 if (Status and 1) /= 1 then
537 if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level then
538 Sys_Cantim (Status, To_Address (Self_ID), 0);
539 pragma Assert ((Status and 1) = 1);
545 (cond => Self_ID.Common.LL.CV'Access,
546 mutex => (if Single_Lock
547 then Single_RTS_Lock'Access
548 else Self_ID.Common.LL.L'Access));
549 pragma Assert (Result = 0);
553 exit when not Self_ID.Common.LL.AST_Pending;
556 Self_ID.Common.State := Runnable;
567 Result := sched_yield;
568 pragma Assert (Result = 0);
572 ---------------------
573 -- Monotonic_Clock --
574 ---------------------
576 function Monotonic_Clock return Duration
577 renames System.OS_Primitives.Monotonic_Clock;
583 function RT_Resolution return Duration is
585 -- Document origin of this magic constant ???
593 procedure Wakeup (T : Task_Id; Reason : System.Tasking.Task_States) is
594 pragma Unreferenced (Reason);
595 Result : Interfaces.C.int;
597 Result := pthread_cond_signal (T.Common.LL.CV'Access);
598 pragma Assert (Result = 0);
605 procedure Yield (Do_Yield : Boolean := True) is
606 Result : Interfaces.C.int;
607 pragma Unreferenced (Result);
610 Result := sched_yield;
618 procedure Set_Priority
620 Prio : System.Any_Priority;
621 Loss_Of_Inheritance : Boolean := False)
623 pragma Unreferenced (Loss_Of_Inheritance);
625 Result : Interfaces.C.int;
626 Param : aliased struct_sched_param;
628 function Get_Policy (Prio : System.Any_Priority) return Character;
629 pragma Import (C, Get_Policy, "__gnat_get_specific_dispatching");
630 -- Get priority specific dispatching policy
632 Priority_Specific_Policy : constant Character := Get_Policy (Prio);
633 -- Upper case first character of the policy name corresponding to the
634 -- task as set by a Priority_Specific_Dispatching pragma.
637 T.Common.Current_Priority := Prio;
638 Param.sched_priority := Interfaces.C.int (Underlying_Priorities (Prio));
640 if Dispatching_Policy = 'R'
641 or else Priority_Specific_Policy = 'R'
642 or else Time_Slice_Val > 0
645 pthread_setschedparam
646 (T.Common.LL.Thread, SCHED_RR, Param'Access);
648 elsif Dispatching_Policy = 'F'
649 or else Priority_Specific_Policy = 'F'
650 or else Time_Slice_Val = 0
653 pthread_setschedparam
654 (T.Common.LL.Thread, SCHED_FIFO, Param'Access);
657 -- SCHED_OTHER priorities are restricted to the range 8 - 15.
658 -- Since the translation from Underlying priorities results
659 -- in a range of 16 - 31, dividing by 2 gives the correct result.
661 Param.sched_priority := Param.sched_priority / 2;
663 pthread_setschedparam
664 (T.Common.LL.Thread, SCHED_OTHER, Param'Access);
667 pragma Assert (Result = 0);
674 function Get_Priority (T : Task_Id) return System.Any_Priority is
676 return T.Common.Current_Priority;
683 procedure Enter_Task (Self_ID : Task_Id) is
685 Self_ID.Common.LL.Thread := pthread_self;
686 Specific.Set (Self_ID);
693 function Is_Valid_Task return Boolean renames Specific.Is_Valid_Task;
695 -----------------------------
696 -- Register_Foreign_Thread --
697 -----------------------------
699 function Register_Foreign_Thread return Task_Id is
701 if Is_Valid_Task then
704 return Register_Foreign_Thread (pthread_self);
706 end Register_Foreign_Thread;
712 procedure Initialize_TCB (Self_ID : Task_Id; Succeeded : out Boolean) is
713 Mutex_Attr : aliased pthread_mutexattr_t;
714 Result : Interfaces.C.int;
715 Cond_Attr : aliased pthread_condattr_t;
718 -- More comments required in body below ???
720 if not Single_Lock then
721 Result := pthread_mutexattr_init (Mutex_Attr'Access);
722 pragma Assert (Result = 0 or else Result = ENOMEM);
727 (Self_ID.Common.LL.L'Access, Mutex_Attr'Access);
728 pragma Assert (Result = 0 or else Result = ENOMEM);
736 Result := pthread_mutexattr_destroy (Mutex_Attr'Access);
737 pragma Assert (Result = 0);
740 Result := pthread_condattr_init (Cond_Attr'Access);
741 pragma Assert (Result = 0 or else Result = ENOMEM);
746 (Self_ID.Common.LL.CV'Access, Cond_Attr'Access);
747 pragma Assert (Result = 0 or else Result = ENOMEM);
754 if not Single_Lock then
755 Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access);
756 pragma Assert (Result = 0);
762 Result := pthread_condattr_destroy (Cond_Attr'Access);
763 pragma Assert (Result = 0);
770 procedure Create_Task
772 Wrapper : System.Address;
773 Stack_Size : System.Parameters.Size_Type;
774 Priority : System.Any_Priority;
775 Succeeded : out Boolean)
777 Attributes : aliased pthread_attr_t;
778 Result : Interfaces.C.int;
780 function Thread_Body_Access is new
781 Ada.Unchecked_Conversion (System.Aux_DEC.Short_Address, Thread_Body);
784 -- Since the initial signal mask of a thread is inherited from the
785 -- creator, we need to set our local signal mask to mask all signals
786 -- during the creation operation, to make sure the new thread is
787 -- not disturbed by signals before it has set its own Task_Id.
789 Result := pthread_attr_init (Attributes'Access);
790 pragma Assert (Result = 0 or else Result = ENOMEM);
797 Result := pthread_attr_setdetachstate
798 (Attributes'Access, PTHREAD_CREATE_DETACHED);
799 pragma Assert (Result = 0);
801 Result := pthread_attr_setstacksize
802 (Attributes'Access, Interfaces.C.size_t (Stack_Size));
803 pragma Assert (Result = 0);
805 -- This call may be unnecessary, not sure. ???
808 pthread_attr_setinheritsched
809 (Attributes'Access, PTHREAD_EXPLICIT_SCHED);
810 pragma Assert (Result = 0);
814 (T.Common.LL.Thread'Access,
816 Thread_Body_Access (Wrapper),
819 -- ENOMEM is a valid run-time error -- do not shut down
821 pragma Assert (Result = 0
822 or else Result = EAGAIN or else Result = ENOMEM);
824 Succeeded := Result = 0;
826 Result := pthread_attr_destroy (Attributes'Access);
827 pragma Assert (Result = 0);
830 Set_Priority (T, Priority);
838 procedure Finalize_TCB (T : Task_Id) is
839 Result : Interfaces.C.int;
842 if not Single_Lock then
843 Result := pthread_mutex_destroy (T.Common.LL.L'Access);
844 pragma Assert (Result = 0);
847 Result := pthread_cond_destroy (T.Common.LL.CV'Access);
848 pragma Assert (Result = 0);
850 if T.Known_Tasks_Index /= -1 then
851 Known_Tasks (T.Known_Tasks_Index) := null;
854 ATCB_Allocation.Free_ATCB (T);
861 procedure Exit_Task is
870 procedure Abort_Task (T : Task_Id) is
872 -- Interrupt Server_Tasks may be waiting on an event flag
874 if T.Common.State = Interrupt_Server_Blocked_On_Event_Flag then
875 Wakeup (T, Interrupt_Server_Blocked_On_Event_Flag);
883 procedure Initialize (S : in out Suspension_Object) is
884 Mutex_Attr : aliased pthread_mutexattr_t;
885 Cond_Attr : aliased pthread_condattr_t;
886 Result : Interfaces.C.int;
888 -- Initialize internal state (always to False (D.10 (6)))
893 -- Initialize internal mutex
895 Result := pthread_mutexattr_init (Mutex_Attr'Access);
896 pragma Assert (Result = 0 or else Result = ENOMEM);
898 if Result = ENOMEM then
902 Result := pthread_mutex_init (S.L'Access, Mutex_Attr'Access);
903 pragma Assert (Result = 0 or else Result = ENOMEM);
905 if Result = ENOMEM then
906 Result := pthread_mutexattr_destroy (Mutex_Attr'Access);
907 pragma Assert (Result = 0);
912 Result := pthread_mutexattr_destroy (Mutex_Attr'Access);
913 pragma Assert (Result = 0);
915 -- Initialize internal condition variable
917 Result := pthread_condattr_init (Cond_Attr'Access);
918 pragma Assert (Result = 0 or else Result = ENOMEM);
921 Result := pthread_mutex_destroy (S.L'Access);
922 pragma Assert (Result = 0);
924 if Result = ENOMEM then
929 Result := pthread_cond_init (S.CV'Access, Cond_Attr'Access);
930 pragma Assert (Result = 0 or else Result = ENOMEM);
933 Result := pthread_mutex_destroy (S.L'Access);
934 pragma Assert (Result = 0);
936 if Result = ENOMEM then
937 Result := pthread_condattr_destroy (Cond_Attr'Access);
938 pragma Assert (Result = 0);
944 Result := pthread_condattr_destroy (Cond_Attr'Access);
945 pragma Assert (Result = 0);
952 procedure Finalize (S : in out Suspension_Object) is
953 Result : Interfaces.C.int;
956 -- Destroy internal mutex
958 Result := pthread_mutex_destroy (S.L'Access);
959 pragma Assert (Result = 0);
961 -- Destroy internal condition variable
963 Result := pthread_cond_destroy (S.CV'Access);
964 pragma Assert (Result = 0);
971 function Current_State (S : Suspension_Object) return Boolean is
973 -- We do not want to use lock on this read operation. State is marked
974 -- as Atomic so that we ensure that the value retrieved is correct.
983 procedure Set_False (S : in out Suspension_Object) is
984 Result : Interfaces.C.int;
989 Result := pthread_mutex_lock (S.L'Access);
990 pragma Assert (Result = 0);
994 Result := pthread_mutex_unlock (S.L'Access);
995 pragma Assert (Result = 0);
997 SSL.Abort_Undefer.all;
1004 procedure Set_True (S : in out Suspension_Object) is
1005 Result : Interfaces.C.int;
1008 SSL.Abort_Defer.all;
1010 Result := pthread_mutex_lock (S.L'Access);
1011 pragma Assert (Result = 0);
1013 -- If there is already a task waiting on this suspension object then
1014 -- we resume it, leaving the state of the suspension object to False,
1015 -- as specified in (RM D.10(9)), otherwise leave state set to True.
1021 Result := pthread_cond_signal (S.CV'Access);
1022 pragma Assert (Result = 0);
1028 Result := pthread_mutex_unlock (S.L'Access);
1029 pragma Assert (Result = 0);
1031 SSL.Abort_Undefer.all;
1034 ------------------------
1035 -- Suspend_Until_True --
1036 ------------------------
1038 procedure Suspend_Until_True (S : in out Suspension_Object) is
1039 Result : Interfaces.C.int;
1042 SSL.Abort_Defer.all;
1044 Result := pthread_mutex_lock (S.L'Access);
1045 pragma Assert (Result = 0);
1049 -- Program_Error must be raised upon calling Suspend_Until_True
1050 -- if another task is already waiting on that suspension object
1053 Result := pthread_mutex_unlock (S.L'Access);
1054 pragma Assert (Result = 0);
1056 SSL.Abort_Undefer.all;
1058 raise Program_Error;
1061 -- Suspend the task if the state is False. Otherwise, the task
1062 -- continues its execution, and the state of the suspension object
1063 -- is set to False (ARM D.10 par. 9).
1071 -- Loop in case pthread_cond_wait returns earlier than expected
1072 -- (e.g. in case of EINTR caused by a signal).
1074 Result := pthread_cond_wait (S.CV'Access, S.L'Access);
1075 pragma Assert (Result = 0 or else Result = EINTR);
1077 exit when not S.Waiting;
1081 Result := pthread_mutex_unlock (S.L'Access);
1082 pragma Assert (Result = 0);
1084 SSL.Abort_Undefer.all;
1086 end Suspend_Until_True;
1094 function Check_Exit (Self_ID : ST.Task_Id) return Boolean is
1095 pragma Unreferenced (Self_ID);
1100 --------------------
1101 -- Check_No_Locks --
1102 --------------------
1104 function Check_No_Locks (Self_ID : ST.Task_Id) return Boolean is
1105 pragma Unreferenced (Self_ID);
1110 ----------------------
1111 -- Environment_Task --
1112 ----------------------
1114 function Environment_Task return Task_Id is
1116 return Environment_Task_Id;
1117 end Environment_Task;
1123 procedure Lock_RTS is
1125 Write_Lock (Single_RTS_Lock'Access, Global_Lock => True);
1132 procedure Unlock_RTS is
1134 Unlock (Single_RTS_Lock'Access, Global_Lock => True);
1141 function Suspend_Task
1143 Thread_Self : Thread_Id) return Boolean
1145 pragma Unreferenced (T);
1146 pragma Unreferenced (Thread_Self);
1155 function Resume_Task
1157 Thread_Self : Thread_Id) return Boolean
1159 pragma Unreferenced (T);
1160 pragma Unreferenced (Thread_Self);
1165 --------------------
1166 -- Stop_All_Tasks --
1167 --------------------
1169 procedure Stop_All_Tasks is
1178 function Stop_Task (T : ST.Task_Id) return Boolean is
1179 pragma Unreferenced (T);
1188 function Continue_Task (T : ST.Task_Id) return Boolean is
1189 pragma Unreferenced (T);
1198 procedure Initialize (Environment_Task : Task_Id) is
1200 -- The DEC Ada facility code defined in Starlet
1201 Ada_Facility : constant := 49;
1203 function DBGEXT (Control_Block : System.Address)
1204 return System.Aux_DEC.Unsigned_Word;
1205 -- DBGEXT is imported from s-tasdeb.adb and its parameter re-typed
1206 -- as Address to avoid having a VMS specific s-tasdeb.ads.
1207 pragma Interface (C, DBGEXT);
1208 pragma Import_Function (DBGEXT, "GNAT$DBGEXT");
1210 type Facility_Type is range 0 .. 65535;
1212 procedure Debug_Register
1213 (ADBGEXT : System.Address;
1214 ATCB_Key : pthread_key_t;
1215 Facility : Facility_Type;
1216 Std_Prolog : Integer);
1217 pragma Import (C, Debug_Register, "CMA$DEBUG_REGISTER");
1219 Environment_Task_Id := Environment_Task;
1221 -- Initialize the lock used to synchronize chain of all ATCBs
1223 Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
1225 Specific.Initialize (Environment_Task);
1227 -- Pass the context key on to CMA along with the other parameters
1230 DBGEXT'Address, -- Our DEBUG handling entry point
1231 ATCB_Key, -- CMA context key for our Ada TCB's
1232 Ada_Facility, -- Out facility code
1233 0 -- False, we don't have the std TCB prolog
1236 -- Make environment task known here because it doesn't go through
1237 -- Activate_Tasks, which does it for all other tasks.
1239 Known_Tasks (Known_Tasks'First) := Environment_Task;
1240 Environment_Task.Known_Tasks_Index := Known_Tasks'First;
1242 Enter_Task (Environment_Task);
1245 -----------------------
1246 -- Set_Task_Affinity --
1247 -----------------------
1249 procedure Set_Task_Affinity (T : ST.Task_Id) is
1250 pragma Unreferenced (T);
1253 -- Setting task affinity is not supported by the underlying system
1256 end Set_Task_Affinity;
1257 end System.Task_Primitives.Operations;