1 ------------------------------------------------------------------------------
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S --
11 -- Copyright (C) 1992-2002, Free Software Foundation, Inc. --
13 -- GNARL is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNARL; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
31 -- GNARL was developed by the GNARL team at Florida State University. It is --
32 -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). --
34 ------------------------------------------------------------------------------
36 -- This is a NT (native) version of this package.
38 -- This package contains all the GNULL primitives that interface directly
39 -- with the underlying OS.
42 -- Turn off polling, we do not want ATC polling to take place during
43 -- tasking operations. It causes infinite loops and other problems.
45 with System.Tasking.Debug;
46 -- used for Known_Tasks
52 with Interfaces.C.Strings;
55 with System.OS_Interface;
56 -- used for various type, constant, and operations
58 with System.Parameters;
62 -- used for Ada_Task_Control_Block
65 with System.Soft_Links;
66 -- used for Defer/Undefer_Abort
67 -- to initialize TSD for a C thread, in function Self
69 -- Note that we do not use System.Tasking.Initialization directly since
70 -- this is a higher level package that we shouldn't depend on. For example
71 -- when using the restricted run time, it is replaced by
72 -- System.Tasking.Restricted.Initialization
74 with System.OS_Primitives;
75 -- used for Delay_Modes
77 with System.Task_Info;
78 -- used for Unspecified_Task_Info
80 with Unchecked_Conversion;
81 with Unchecked_Deallocation;
83 package body System.Task_Primitives.Operations is
85 use System.Tasking.Debug;
88 use Interfaces.C.Strings;
89 use System.OS_Interface;
90 use System.Parameters;
91 use System.OS_Primitives;
93 pragma Link_With ("-Xlinker --stack=0x800000,0x1000");
94 -- Change the stack size (8 MB) for tasking programs on Windows. This
95 -- permit to have more than 30 tasks running at the same time. Note that
96 -- we set the stack size for non tasking programs on System unit.
98 package SSL renames System.Soft_Links;
104 Environment_Task_ID : Task_ID;
105 -- A variable to hold Task_ID for the environment task.
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 Time_Slice_Val : Integer;
113 pragma Import (C, Time_Slice_Val, "__gl_time_slice_val");
115 Dispatching_Policy : Character;
116 pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
118 FIFO_Within_Priorities : constant Boolean := Dispatching_Policy = 'F';
119 -- Indicates whether FIFO_Within_Priorities is set.
121 ---------------------------------
122 -- Foreign Threads Detection --
123 ---------------------------------
125 -- The following are used to allow the Self function to
126 -- automatically generate ATCB's for C threads that happen to call
127 -- Ada procedure, which in turn happen to call the Ada run-time system.
130 type Fake_ATCB_Ptr is access Fake_ATCB;
131 type Fake_ATCB is record
132 Stack_Base : Interfaces.C.unsigned := 0;
133 -- A value of zero indicates the node is not in use.
134 Next : Fake_ATCB_Ptr;
135 Real_ATCB : aliased Ada_Task_Control_Block (0);
138 Fake_ATCB_List : Fake_ATCB_Ptr;
139 -- A linear linked list.
140 -- The list is protected by Single_RTS_Lock;
141 -- Nodes are added to this list from the front.
142 -- Once a node is added to this list, it is never removed.
144 Fake_Task_Elaborated : aliased Boolean := True;
145 -- Used to identified fake tasks (i.e., non-Ada Threads).
147 Next_Fake_ATCB : Fake_ATCB_Ptr;
148 -- Used to allocate one Fake_ATCB in advance. See comment in New_Fake_ATCB
150 ---------------------------------
151 -- Support for New_Fake_ATCB --
152 ---------------------------------
154 function New_Fake_ATCB return Task_ID;
155 -- Allocate and Initialize a new ATCB. This code can safely be called from
156 -- a foreign thread, as it doesn't access implicitly or explicitly
157 -- "self" before having initialized the new ATCB.
159 ------------------------------------
160 -- The thread local storage index --
161 ------------------------------------
164 pragma Export (Ada, TlsIndex);
165 -- To ensure that this variable won't be local to this package, since
166 -- in some cases, inlining forces this variable to be global anyway.
168 ----------------------------------
169 -- Utility Conversion Functions --
170 ----------------------------------
172 function To_Task_Id is new Unchecked_Conversion (System.Address, Task_ID);
174 function To_Address is new Unchecked_Conversion (Task_ID, System.Address);
180 function New_Fake_ATCB return Task_ID is
182 P, Q : Fake_ATCB_Ptr;
187 -- This section is ticklish.
188 -- We dare not call anything that might require an ATCB, until
189 -- we have the new ATCB in place.
196 if P.Stack_Base = 0 then
205 -- Create a new ATCB with zero entries.
207 Self_ID := Next_Fake_ATCB.Real_ATCB'Access;
208 Next_Fake_ATCB.Stack_Base := 1;
209 Next_Fake_ATCB.Next := Fake_ATCB_List;
210 Fake_ATCB_List := Next_Fake_ATCB;
211 Next_Fake_ATCB := null;
214 -- Reuse an existing fake ATCB.
216 Self_ID := Q.Real_ATCB'Access;
220 -- Record this as the Task_ID for the current thread.
222 Self_ID.Common.LL.Thread := GetCurrentThread;
224 Res := TlsSetValue (TlsIndex, To_Address (Self_ID));
225 pragma Assert (Res = True);
227 -- Do the standard initializations
229 System.Tasking.Initialize_ATCB
230 (Self_ID, null, Null_Address, Null_Task, Fake_Task_Elaborated'Access,
231 System.Priority'First, Task_Info.Unspecified_Task_Info, 0, Self_ID,
233 pragma Assert (Succeeded);
235 -- Finally, it is safe to use an allocator in this thread.
237 if Next_Fake_ATCB = null then
238 Next_Fake_ATCB := new Fake_ATCB;
241 Self_ID.Master_of_Task := 0;
242 Self_ID.Master_Within := Self_ID.Master_of_Task + 1;
244 for L in Self_ID.Entry_Calls'Range loop
245 Self_ID.Entry_Calls (L).Self := Self_ID;
246 Self_ID.Entry_Calls (L).Level := L;
249 Self_ID.Common.State := Runnable;
250 Self_ID.Awake_Count := 1;
252 -- Since this is not an ordinary Ada task, we will start out undeferred
254 Self_ID.Deferral_Level := 0;
256 System.Soft_Links.Create_TSD (Self_ID.Common.Compiler_Data);
259 -- The following call is commented out to avoid dependence on
260 -- the System.Tasking.Initialization package.
261 -- It seems that if we want Ada.Task_Attributes to work correctly
262 -- for C threads we will need to raise the visibility of this soft
263 -- link to System.Soft_Links.
264 -- We are putting that off until this new functionality is otherwise
266 -- System.Tasking.Initialization.Initialize_Attributes_Link.all (T);
268 -- Must not unlock until Next_ATCB is again allocated.
274 ----------------------------------
275 -- Condition Variable Functions --
276 ----------------------------------
278 procedure Initialize_Cond (Cond : access Condition_Variable);
279 -- Initialize given condition variable Cond
281 procedure Finalize_Cond (Cond : access Condition_Variable);
282 -- Finalize given condition variable Cond.
284 procedure Cond_Signal (Cond : access Condition_Variable);
285 -- Signal condition variable Cond
288 (Cond : access Condition_Variable;
289 L : access RTS_Lock);
290 -- Wait on conditional variable Cond, using lock L
292 procedure Cond_Timed_Wait
293 (Cond : access Condition_Variable;
296 Timed_Out : out Boolean;
297 Status : out Integer);
298 -- Do timed wait on condition variable Cond using lock L. The duration
299 -- of the timed wait is given by Rel_Time. When the condition is
300 -- signalled, Timed_Out shows whether or not a time out occurred.
301 -- Status shows whether Cond_Timed_Wait completed successfully.
303 ---------------------
304 -- Initialize_Cond --
305 ---------------------
307 procedure Initialize_Cond (Cond : access Condition_Variable) is
311 hEvent := CreateEvent (null, True, False, Null_Ptr);
312 pragma Assert (hEvent /= 0);
313 Cond.all := Condition_Variable (hEvent);
320 -- No such problem here, DosCloseEventSem has been derived.
321 -- What does such refer to in above comment???
323 procedure Finalize_Cond (Cond : access Condition_Variable) is
327 Result := CloseHandle (HANDLE (Cond.all));
328 pragma Assert (Result = True);
335 procedure Cond_Signal (Cond : access Condition_Variable) is
339 Result := SetEvent (HANDLE (Cond.all));
340 pragma Assert (Result = True);
347 -- Pre-assertion: Cond is posted
350 -- Post-assertion: Cond is posted
354 (Cond : access Condition_Variable;
361 -- Must reset Cond BEFORE L is unlocked.
363 Result_Bool := ResetEvent (HANDLE (Cond.all));
364 pragma Assert (Result_Bool = True);
367 -- No problem if we are interrupted here: if the condition is signaled,
368 -- WaitForSingleObject will simply not block
370 Result := WaitForSingleObject (HANDLE (Cond.all), Wait_Infinite);
371 pragma Assert (Result = 0);
376 ---------------------
377 -- Cond_Timed_Wait --
378 ---------------------
380 -- Pre-assertion: Cond is posted
383 -- Post-assertion: Cond is posted
386 procedure Cond_Timed_Wait
387 (Cond : access Condition_Variable;
390 Timed_Out : out Boolean;
391 Status : out Integer)
396 Int_Rel_Time : DWORD;
400 -- Must reset Cond BEFORE L is unlocked.
402 Result := ResetEvent (HANDLE (Cond.all));
403 pragma Assert (Result = True);
406 -- No problem if we are interrupted here: if the condition is signaled,
407 -- WaitForSingleObject will simply not block
409 if Rel_Time <= 0.0 then
412 Int_Rel_Time := DWORD (Rel_Time);
413 Time_Out := Int_Rel_Time * 1000 +
414 DWORD ((Rel_Time - Duration (Int_Rel_Time)) * 1000.0);
415 Wait_Result := WaitForSingleObject (HANDLE (Cond.all), Time_Out);
417 if Wait_Result = WAIT_TIMEOUT then
427 -- Ensure post-condition
430 Result := SetEvent (HANDLE (Cond.all));
431 pragma Assert (Result = True);
434 Status := Integer (Wait_Result);
441 -- The underlying thread system sets a guard page at the
442 -- bottom of a thread stack, so nothing is needed.
443 -- ??? Check the comment above
445 procedure Stack_Guard (T : ST.Task_ID; On : Boolean) is
454 function Get_Thread_Id (T : ST.Task_ID) return OSI.Thread_Id is
456 return T.Common.LL.Thread;
463 function Self return Task_ID is
467 Self_Id := To_Task_Id (TlsGetValue (TlsIndex));
469 if Self_Id = null then
470 return New_Fake_ATCB;
476 ---------------------
477 -- Initialize_Lock --
478 ---------------------
480 -- Note: mutexes and cond_variables needed per-task basis are
481 -- initialized in Initialize_TCB and the Storage_Error is handled.
482 -- Other mutexes (such as RTS_Lock, Memory_Lock...) used in
483 -- the RTS is initialized before any status change of RTS.
484 -- Therefore raising Storage_Error in the following routines
485 -- should be able to be handled safely.
487 procedure Initialize_Lock
488 (Prio : System.Any_Priority;
491 InitializeCriticalSection (L.Mutex'Access);
492 L.Owner_Priority := 0;
496 procedure Initialize_Lock (L : access RTS_Lock; Level : Lock_Level) is
498 InitializeCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access);
505 procedure Finalize_Lock (L : access Lock) is
507 DeleteCriticalSection (L.Mutex'Access);
510 procedure Finalize_Lock (L : access RTS_Lock) is
512 DeleteCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access);
519 procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is
521 L.Owner_Priority := Get_Priority (Self);
523 if L.Priority < L.Owner_Priority then
524 Ceiling_Violation := True;
528 EnterCriticalSection (L.Mutex'Access);
530 Ceiling_Violation := False;
534 (L : access RTS_Lock; Global_Lock : Boolean := False) is
536 if not Single_Lock or else Global_Lock then
537 EnterCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access);
541 procedure Write_Lock (T : Task_ID) is
543 if not Single_Lock then
545 (CRITICAL_SECTION (T.Common.LL.L)'Unrestricted_Access);
553 procedure Read_Lock (L : access Lock; Ceiling_Violation : out Boolean) is
555 Write_Lock (L, Ceiling_Violation);
562 procedure Unlock (L : access Lock) is
564 LeaveCriticalSection (L.Mutex'Access);
567 procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is
569 if not Single_Lock or else Global_Lock then
570 LeaveCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access);
574 procedure Unlock (T : Task_ID) is
576 if not Single_Lock then
578 (CRITICAL_SECTION (T.Common.LL.L)'Unrestricted_Access);
588 Reason : System.Tasking.Task_States) is
590 pragma Assert (Self_ID = Self);
593 Cond_Wait (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access);
595 Cond_Wait (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access);
598 if Self_ID.Deferral_Level = 0
599 and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level
602 raise Standard'Abort_Signal;
610 -- This is for use within the run-time system, so abort is
611 -- assumed to be already deferred, and the caller should be
612 -- holding its own ATCB lock.
614 procedure Timed_Sleep
617 Mode : ST.Delay_Modes;
618 Reason : System.Tasking.Task_States;
619 Timedout : out Boolean;
620 Yielded : out Boolean)
622 Check_Time : constant Duration := Monotonic_Clock;
627 Local_Timedout : Boolean;
633 if Mode = Relative then
635 Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time;
637 Rel_Time := Time - Check_Time;
641 if Rel_Time > 0.0 then
643 exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level
644 or else Self_ID.Pending_Priority_Change;
647 Cond_Timed_Wait (Self_ID.Common.LL.CV'Access,
648 Single_RTS_Lock'Access, Rel_Time, Local_Timedout, Result);
650 Cond_Timed_Wait (Self_ID.Common.LL.CV'Access,
651 Self_ID.Common.LL.L'Access, Rel_Time, Local_Timedout, Result);
654 exit when Abs_Time <= Monotonic_Clock;
656 if not Local_Timedout then
657 -- somebody may have called Wakeup for us
662 Rel_Time := Abs_Time - Monotonic_Clock;
671 procedure Timed_Delay
674 Mode : ST.Delay_Modes)
676 Check_Time : constant Duration := Monotonic_Clock;
683 -- Only the little window between deferring abort and
684 -- locking Self_ID is the reason we need to
685 -- check for pending abort and priority change below!
693 Write_Lock (Self_ID);
695 if Mode = Relative then
697 Abs_Time := Time + Check_Time;
699 Rel_Time := Time - Check_Time;
703 if Rel_Time > 0.0 then
704 Self_ID.Common.State := Delay_Sleep;
707 if Self_ID.Pending_Priority_Change then
708 Self_ID.Pending_Priority_Change := False;
709 Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority;
710 Set_Priority (Self_ID, Self_ID.Common.Base_Priority);
713 exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level;
716 Cond_Timed_Wait (Self_ID.Common.LL.CV'Access,
717 Single_RTS_Lock'Access, Rel_Time, Timedout, Result);
719 Cond_Timed_Wait (Self_ID.Common.LL.CV'Access,
720 Self_ID.Common.LL.L'Access, Rel_Time, Timedout, Result);
723 exit when Abs_Time <= Monotonic_Clock;
725 Rel_Time := Abs_Time - Monotonic_Clock;
728 Self_ID.Common.State := Runnable;
738 SSL.Abort_Undefer.all;
745 procedure Wakeup (T : Task_ID; Reason : System.Tasking.Task_States) is
747 Cond_Signal (T.Common.LL.CV'Access);
754 procedure Yield (Do_Yield : Boolean := True) is
765 type Prio_Array_Type is array (System.Any_Priority) of Integer;
766 pragma Atomic_Components (Prio_Array_Type);
768 Prio_Array : Prio_Array_Type;
769 -- Global array containing the id of the currently running task for
772 -- Note: we assume that we are on a single processor with run-til-blocked
775 procedure Set_Priority
777 Prio : System.Any_Priority;
778 Loss_Of_Inheritance : Boolean := False)
781 Array_Item : Integer;
784 Res := SetThreadPriority
785 (T.Common.LL.Thread, Interfaces.C.int (Underlying_Priorities (Prio)));
786 pragma Assert (Res = True);
788 -- ??? Work around a bug in NT 4.0 SP3 scheduler
789 -- It looks like when a task with Thread_Priority_Idle (using RT class)
790 -- never reaches its time slice (e.g by doing multiple and simple RV,
791 -- see CXD8002), the scheduler never gives higher priority task a
793 -- Note that this works fine on NT 4.0 SP1
795 if Time_Slice_Val = 0
796 and then Underlying_Priorities (Prio) = Thread_Priority_Idle
797 and then Loss_Of_Inheritance
802 if FIFO_Within_Priorities then
804 -- Annex D requirement [RM D.2.2 par. 9]:
805 -- If the task drops its priority due to the loss of inherited
806 -- priority, it is added at the head of the ready queue for its
807 -- new active priority.
809 if Loss_Of_Inheritance
810 and then Prio < T.Common.Current_Priority
812 Array_Item := Prio_Array (T.Common.Base_Priority) + 1;
813 Prio_Array (T.Common.Base_Priority) := Array_Item;
816 -- Let some processes a chance to arrive
820 -- Then wait for our turn to proceed
822 exit when Array_Item = Prio_Array (T.Common.Base_Priority)
823 or else Prio_Array (T.Common.Base_Priority) = 1;
826 Prio_Array (T.Common.Base_Priority) :=
827 Prio_Array (T.Common.Base_Priority) - 1;
831 T.Common.Current_Priority := Prio;
838 function Get_Priority (T : Task_ID) return System.Any_Priority is
840 return T.Common.Current_Priority;
847 -- There were two paths were we needed to call Enter_Task :
848 -- 1) from System.Task_Primitives.Operations.Initialize
849 -- 2) from System.Tasking.Stages.Task_Wrapper
851 -- The thread initialisation has to be done only for the first case.
853 -- This is because the GetCurrentThread NT call does not return the
854 -- real thread handler but only a "pseudo" one. It is not possible to
855 -- release the thread handle and free the system ressources from this
856 -- "pseudo" handle. So we really want to keep the real thread handle
857 -- set in System.Task_Primitives.Operations.Create_Task during the
860 procedure Enter_Task (Self_ID : Task_ID) is
861 procedure Init_Float;
862 pragma Import (C, Init_Float, "__gnat_init_float");
863 -- Properly initializes the FPU for x86 systems.
868 Succeeded := TlsSetValue (TlsIndex, To_Address (Self_ID));
869 pragma Assert (Succeeded = True);
872 Self_ID.Common.LL.Thread_Id := GetCurrentThreadId;
876 for J in Known_Tasks'Range loop
877 if Known_Tasks (J) = null then
878 Known_Tasks (J) := Self_ID;
879 Self_ID.Known_Tasks_Index := J;
891 function New_ATCB (Entry_Num : Task_Entry_Index) return Task_ID is
893 return new Ada_Task_Control_Block (Entry_Num);
900 procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is
902 Initialize_Cond (Self_ID.Common.LL.CV'Access);
904 if not Single_Lock then
905 Initialize_Lock (Self_ID.Common.LL.L'Access, ATCB_Level);
915 procedure Create_Task
917 Wrapper : System.Address;
918 Stack_Size : System.Parameters.Size_Type;
919 Priority : System.Any_Priority;
920 Succeeded : out Boolean)
923 TaskId : aliased DWORD;
924 pTaskParameter : System.OS_Interface.PVOID;
927 Entry_Point : PTHREAD_START_ROUTINE;
929 function To_PTHREAD_START_ROUTINE is new
930 Unchecked_Conversion (System.Address, PTHREAD_START_ROUTINE);
933 pTaskParameter := To_Address (T);
935 if Stack_Size = Unspecified_Size then
936 dwStackSize := DWORD (Default_Stack_Size);
938 elsif Stack_Size < Minimum_Stack_Size then
939 dwStackSize := DWORD (Minimum_Stack_Size);
942 dwStackSize := DWORD (Stack_Size);
945 Entry_Point := To_PTHREAD_START_ROUTINE (Wrapper);
947 hTask := CreateThread
952 DWORD (Create_Suspended),
953 TaskId'Unchecked_Access);
955 -- Step 1: Create the thread in blocked mode
961 -- Step 2: set its TCB
963 T.Common.LL.Thread := hTask;
965 -- Step 3: set its priority (child has inherited priority from parent)
967 Set_Priority (T, Priority);
969 -- Step 4: Now, start it for good:
971 Result := ResumeThread (hTask);
972 pragma Assert (Result = 1);
974 Succeeded := Result = 1;
981 procedure Finalize_TCB (T : Task_ID) is
982 Self_ID : Task_ID := T;
986 procedure Free is new
987 Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID);
990 if not Single_Lock then
991 Finalize_Lock (T.Common.LL.L'Access);
994 Finalize_Cond (T.Common.LL.CV'Access);
996 if T.Known_Tasks_Index /= -1 then
997 Known_Tasks (T.Known_Tasks_Index) := null;
1000 -- Wait for the thread to terminate then close it. this is needed
1001 -- to release system ressources.
1003 Result := WaitForSingleObject (T.Common.LL.Thread, Wait_Infinite);
1004 pragma Assert (Result /= WAIT_FAILED);
1005 Succeeded := CloseHandle (T.Common.LL.Thread);
1006 pragma Assert (Succeeded = True);
1015 procedure Exit_Task is
1024 procedure Abort_Task (T : Task_ID) is
1029 ----------------------
1030 -- Environment_Task --
1031 ----------------------
1033 function Environment_Task return Task_ID is
1035 return Environment_Task_ID;
1036 end Environment_Task;
1042 procedure Lock_RTS is
1044 Write_Lock (Single_RTS_Lock'Access, Global_Lock => True);
1051 procedure Unlock_RTS is
1053 Unlock (Single_RTS_Lock'Access, Global_Lock => True);
1060 procedure Initialize (Environment_Task : Task_ID) is
1063 Environment_Task_ID := Environment_Task;
1065 if Time_Slice_Val = 0 or else FIFO_Within_Priorities then
1066 Res := OS_Interface.SetPriorityClass
1067 (GetCurrentProcess, Realtime_Priority_Class);
1070 TlsIndex := TlsAlloc;
1072 -- Initialize the lock used to synchronize chain of all ATCBs.
1074 Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
1076 Environment_Task.Common.LL.Thread := GetCurrentThread;
1077 Enter_Task (Environment_Task);
1079 -- Create a free ATCB for use on the Fake_ATCB_List
1081 Next_Fake_ATCB := new Fake_ATCB;
1084 ---------------------
1085 -- Monotonic_Clock --
1086 ---------------------
1088 function Monotonic_Clock return Duration
1089 renames System.OS_Primitives.Monotonic_Clock;
1095 function RT_Resolution return Duration is
1097 return 0.000_001; -- 1 micro-second
1104 -- Dummy versions. The only currently working versions is for solaris
1107 function Check_Exit (Self_ID : ST.Task_ID) return Boolean is
1112 --------------------
1113 -- Check_No_Locks --
1114 --------------------
1116 function Check_No_Locks (Self_ID : ST.Task_ID) return Boolean is
1125 function Suspend_Task
1127 Thread_Self : Thread_Id) return Boolean is
1129 if T.Common.LL.Thread /= Thread_Self then
1130 return SuspendThread (T.Common.LL.Thread) = NO_ERROR;
1140 function Resume_Task
1142 Thread_Self : Thread_Id) return Boolean is
1144 if T.Common.LL.Thread /= Thread_Self then
1145 return ResumeThread (T.Common.LL.Thread) = NO_ERROR;
1151 end System.Task_Primitives.Operations;