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 --
9 -- Copyright (C) 1992-2002, 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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 NT (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
50 with Interfaces.C.Strings;
53 with System.OS_Interface;
54 -- used for various type, constant, and operations
56 with System.Parameters;
60 -- used for Ada_Task_Control_Block
63 with System.Soft_Links;
64 -- used for Defer/Undefer_Abort
65 -- to initialize TSD for a C thread, in function Self
67 -- Note that we do not use System.Tasking.Initialization directly since
68 -- this is a higher level package that we shouldn't depend on. For example
69 -- when using the restricted run time, it is replaced by
70 -- System.Tasking.Restricted.Initialization
72 with System.OS_Primitives;
73 -- used for Delay_Modes
75 with System.Task_Info;
76 -- used for Unspecified_Task_Info
78 with Unchecked_Conversion;
79 with Unchecked_Deallocation;
81 package body System.Task_Primitives.Operations is
83 use System.Tasking.Debug;
86 use Interfaces.C.Strings;
87 use System.OS_Interface;
88 use System.Parameters;
89 use System.OS_Primitives;
91 pragma Link_With ("-Xlinker --stack=0x800000,0x1000");
92 -- Change the stack size (8 MB) for tasking programs on Windows. This
93 -- permit to have more than 30 tasks running at the same time. Note that
94 -- we set the stack size for non tasking programs on System unit.
96 package SSL renames System.Soft_Links;
102 Environment_Task_ID : Task_ID;
103 -- A variable to hold Task_ID for the environment task.
105 Single_RTS_Lock : aliased RTS_Lock;
106 -- This is a lock to allow only one thread of control in the RTS at
107 -- a time; it is used to execute in mutual exclusion from all other tasks.
108 -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List
110 Time_Slice_Val : Integer;
111 pragma Import (C, Time_Slice_Val, "__gl_time_slice_val");
113 Dispatching_Policy : Character;
114 pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
116 FIFO_Within_Priorities : constant Boolean := Dispatching_Policy = 'F';
117 -- Indicates whether FIFO_Within_Priorities is set.
119 ---------------------------------
120 -- Foreign Threads Detection --
121 ---------------------------------
123 -- The following are used to allow the Self function to
124 -- automatically generate ATCB's for C threads that happen to call
125 -- Ada procedure, which in turn happen to call the Ada run-time system.
128 type Fake_ATCB_Ptr is access Fake_ATCB;
129 type Fake_ATCB is record
130 Stack_Base : Interfaces.C.unsigned := 0;
131 -- A value of zero indicates the node is not in use.
132 Next : Fake_ATCB_Ptr;
133 Real_ATCB : aliased Ada_Task_Control_Block (0);
136 Fake_ATCB_List : Fake_ATCB_Ptr;
137 -- A linear linked list.
138 -- The list is protected by Single_RTS_Lock;
139 -- Nodes are added to this list from the front.
140 -- Once a node is added to this list, it is never removed.
142 Fake_Task_Elaborated : aliased Boolean := True;
143 -- Used to identified fake tasks (i.e., non-Ada Threads).
145 Next_Fake_ATCB : Fake_ATCB_Ptr;
146 -- Used to allocate one Fake_ATCB in advance. See comment in New_Fake_ATCB
148 ---------------------------------
149 -- Support for New_Fake_ATCB --
150 ---------------------------------
152 function New_Fake_ATCB return Task_ID;
153 -- Allocate and Initialize a new ATCB. This code can safely be called from
154 -- a foreign thread, as it doesn't access implicitly or explicitly
155 -- "self" before having initialized the new ATCB.
157 ------------------------------------
158 -- The thread local storage index --
159 ------------------------------------
162 pragma Export (Ada, TlsIndex);
163 -- To ensure that this variable won't be local to this package, since
164 -- in some cases, inlining forces this variable to be global anyway.
166 ----------------------------------
167 -- Utility Conversion Functions --
168 ----------------------------------
170 function To_Task_Id is new Unchecked_Conversion (System.Address, Task_ID);
172 function To_Address is new Unchecked_Conversion (Task_ID, System.Address);
178 function New_Fake_ATCB return Task_ID is
180 P, Q : Fake_ATCB_Ptr;
185 -- This section is ticklish.
186 -- We dare not call anything that might require an ATCB, until
187 -- we have the new ATCB in place.
194 if P.Stack_Base = 0 then
203 -- Create a new ATCB with zero entries.
205 Self_ID := Next_Fake_ATCB.Real_ATCB'Access;
206 Next_Fake_ATCB.Stack_Base := 1;
207 Next_Fake_ATCB.Next := Fake_ATCB_List;
208 Fake_ATCB_List := Next_Fake_ATCB;
209 Next_Fake_ATCB := null;
212 -- Reuse an existing fake ATCB.
214 Self_ID := Q.Real_ATCB'Access;
218 -- Record this as the Task_ID for the current thread.
220 Self_ID.Common.LL.Thread := GetCurrentThread;
222 Res := TlsSetValue (TlsIndex, To_Address (Self_ID));
223 pragma Assert (Res = True);
225 -- Do the standard initializations
227 System.Tasking.Initialize_ATCB
228 (Self_ID, null, Null_Address, Null_Task, Fake_Task_Elaborated'Access,
229 System.Priority'First, Task_Info.Unspecified_Task_Info, 0, Self_ID,
231 pragma Assert (Succeeded);
233 -- Finally, it is safe to use an allocator in this thread.
235 if Next_Fake_ATCB = null then
236 Next_Fake_ATCB := new Fake_ATCB;
239 Self_ID.Master_of_Task := 0;
240 Self_ID.Master_Within := Self_ID.Master_of_Task + 1;
242 for L in Self_ID.Entry_Calls'Range loop
243 Self_ID.Entry_Calls (L).Self := Self_ID;
244 Self_ID.Entry_Calls (L).Level := L;
247 Self_ID.Common.State := Runnable;
248 Self_ID.Awake_Count := 1;
250 -- Since this is not an ordinary Ada task, we will start out undeferred
252 Self_ID.Deferral_Level := 0;
254 System.Soft_Links.Create_TSD (Self_ID.Common.Compiler_Data);
257 -- The following call is commented out to avoid dependence on
258 -- the System.Tasking.Initialization package.
259 -- It seems that if we want Ada.Task_Attributes to work correctly
260 -- for C threads we will need to raise the visibility of this soft
261 -- link to System.Soft_Links.
262 -- We are putting that off until this new functionality is otherwise
264 -- System.Tasking.Initialization.Initialize_Attributes_Link.all (T);
266 -- Must not unlock until Next_ATCB is again allocated.
272 ----------------------------------
273 -- Condition Variable Functions --
274 ----------------------------------
276 procedure Initialize_Cond (Cond : access Condition_Variable);
277 -- Initialize given condition variable Cond
279 procedure Finalize_Cond (Cond : access Condition_Variable);
280 -- Finalize given condition variable Cond.
282 procedure Cond_Signal (Cond : access Condition_Variable);
283 -- Signal condition variable Cond
286 (Cond : access Condition_Variable;
287 L : access RTS_Lock);
288 -- Wait on conditional variable Cond, using lock L
290 procedure Cond_Timed_Wait
291 (Cond : access Condition_Variable;
294 Timed_Out : out Boolean;
295 Status : out Integer);
296 -- Do timed wait on condition variable Cond using lock L. The duration
297 -- of the timed wait is given by Rel_Time. When the condition is
298 -- signalled, Timed_Out shows whether or not a time out occurred.
299 -- Status shows whether Cond_Timed_Wait completed successfully.
301 ---------------------
302 -- Initialize_Cond --
303 ---------------------
305 procedure Initialize_Cond (Cond : access Condition_Variable) is
309 hEvent := CreateEvent (null, True, False, Null_Ptr);
310 pragma Assert (hEvent /= 0);
311 Cond.all := Condition_Variable (hEvent);
318 -- No such problem here, DosCloseEventSem has been derived.
319 -- What does such refer to in above comment???
321 procedure Finalize_Cond (Cond : access Condition_Variable) is
325 Result := CloseHandle (HANDLE (Cond.all));
326 pragma Assert (Result = True);
333 procedure Cond_Signal (Cond : access Condition_Variable) is
337 Result := SetEvent (HANDLE (Cond.all));
338 pragma Assert (Result = True);
345 -- Pre-assertion: Cond is posted
348 -- Post-assertion: Cond is posted
352 (Cond : access Condition_Variable;
359 -- Must reset Cond BEFORE L is unlocked.
361 Result_Bool := ResetEvent (HANDLE (Cond.all));
362 pragma Assert (Result_Bool = True);
365 -- No problem if we are interrupted here: if the condition is signaled,
366 -- WaitForSingleObject will simply not block
368 Result := WaitForSingleObject (HANDLE (Cond.all), Wait_Infinite);
369 pragma Assert (Result = 0);
374 ---------------------
375 -- Cond_Timed_Wait --
376 ---------------------
378 -- Pre-assertion: Cond is posted
381 -- Post-assertion: Cond is posted
384 procedure Cond_Timed_Wait
385 (Cond : access Condition_Variable;
388 Timed_Out : out Boolean;
389 Status : out Integer)
394 Int_Rel_Time : DWORD;
398 -- Must reset Cond BEFORE L is unlocked.
400 Result := ResetEvent (HANDLE (Cond.all));
401 pragma Assert (Result = True);
404 -- No problem if we are interrupted here: if the condition is signaled,
405 -- WaitForSingleObject will simply not block
407 if Rel_Time <= 0.0 then
410 Int_Rel_Time := DWORD (Rel_Time);
411 Time_Out := Int_Rel_Time * 1000 +
412 DWORD ((Rel_Time - Duration (Int_Rel_Time)) * 1000.0);
413 Wait_Result := WaitForSingleObject (HANDLE (Cond.all), Time_Out);
415 if Wait_Result = WAIT_TIMEOUT then
425 -- Ensure post-condition
428 Result := SetEvent (HANDLE (Cond.all));
429 pragma Assert (Result = True);
432 Status := Integer (Wait_Result);
439 -- The underlying thread system sets a guard page at the
440 -- bottom of a thread stack, so nothing is needed.
441 -- ??? Check the comment above
443 procedure Stack_Guard (T : ST.Task_ID; On : Boolean) is
452 function Get_Thread_Id (T : ST.Task_ID) return OSI.Thread_Id is
454 return T.Common.LL.Thread;
461 function Self return Task_ID is
465 Self_Id := To_Task_Id (TlsGetValue (TlsIndex));
467 if Self_Id = null then
468 return New_Fake_ATCB;
474 ---------------------
475 -- Initialize_Lock --
476 ---------------------
478 -- Note: mutexes and cond_variables needed per-task basis are
479 -- initialized in Initialize_TCB and the Storage_Error is handled.
480 -- Other mutexes (such as RTS_Lock, Memory_Lock...) used in
481 -- the RTS is initialized before any status change of RTS.
482 -- Therefore raising Storage_Error in the following routines
483 -- should be able to be handled safely.
485 procedure Initialize_Lock
486 (Prio : System.Any_Priority;
489 InitializeCriticalSection (L.Mutex'Access);
490 L.Owner_Priority := 0;
494 procedure Initialize_Lock (L : access RTS_Lock; Level : Lock_Level) is
496 InitializeCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access);
503 procedure Finalize_Lock (L : access Lock) is
505 DeleteCriticalSection (L.Mutex'Access);
508 procedure Finalize_Lock (L : access RTS_Lock) is
510 DeleteCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access);
517 procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is
519 L.Owner_Priority := Get_Priority (Self);
521 if L.Priority < L.Owner_Priority then
522 Ceiling_Violation := True;
526 EnterCriticalSection (L.Mutex'Access);
528 Ceiling_Violation := False;
532 (L : access RTS_Lock; Global_Lock : Boolean := False) is
534 if not Single_Lock or else Global_Lock then
535 EnterCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access);
539 procedure Write_Lock (T : Task_ID) is
541 if not Single_Lock then
543 (CRITICAL_SECTION (T.Common.LL.L)'Unrestricted_Access);
551 procedure Read_Lock (L : access Lock; Ceiling_Violation : out Boolean) is
553 Write_Lock (L, Ceiling_Violation);
560 procedure Unlock (L : access Lock) is
562 LeaveCriticalSection (L.Mutex'Access);
565 procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is
567 if not Single_Lock or else Global_Lock then
568 LeaveCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access);
572 procedure Unlock (T : Task_ID) is
574 if not Single_Lock then
576 (CRITICAL_SECTION (T.Common.LL.L)'Unrestricted_Access);
586 Reason : System.Tasking.Task_States) is
588 pragma Assert (Self_ID = Self);
591 Cond_Wait (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access);
593 Cond_Wait (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access);
596 if Self_ID.Deferral_Level = 0
597 and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level
600 raise Standard'Abort_Signal;
608 -- This is for use within the run-time system, so abort is
609 -- assumed to be already deferred, and the caller should be
610 -- holding its own ATCB lock.
612 procedure Timed_Sleep
615 Mode : ST.Delay_Modes;
616 Reason : System.Tasking.Task_States;
617 Timedout : out Boolean;
618 Yielded : out Boolean)
620 Check_Time : constant Duration := Monotonic_Clock;
625 Local_Timedout : Boolean;
631 if Mode = Relative then
633 Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time;
635 Rel_Time := Time - Check_Time;
639 if Rel_Time > 0.0 then
641 exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level
642 or else Self_ID.Pending_Priority_Change;
645 Cond_Timed_Wait (Self_ID.Common.LL.CV'Access,
646 Single_RTS_Lock'Access, Rel_Time, Local_Timedout, Result);
648 Cond_Timed_Wait (Self_ID.Common.LL.CV'Access,
649 Self_ID.Common.LL.L'Access, Rel_Time, Local_Timedout, Result);
652 exit when Abs_Time <= Monotonic_Clock;
654 if not Local_Timedout then
655 -- somebody may have called Wakeup for us
660 Rel_Time := Abs_Time - Monotonic_Clock;
669 procedure Timed_Delay
672 Mode : ST.Delay_Modes)
674 Check_Time : constant Duration := Monotonic_Clock;
681 -- Only the little window between deferring abort and
682 -- locking Self_ID is the reason we need to
683 -- check for pending abort and priority change below!
691 Write_Lock (Self_ID);
693 if Mode = Relative then
695 Abs_Time := Time + Check_Time;
697 Rel_Time := Time - Check_Time;
701 if Rel_Time > 0.0 then
702 Self_ID.Common.State := Delay_Sleep;
705 if Self_ID.Pending_Priority_Change then
706 Self_ID.Pending_Priority_Change := False;
707 Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority;
708 Set_Priority (Self_ID, Self_ID.Common.Base_Priority);
711 exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level;
714 Cond_Timed_Wait (Self_ID.Common.LL.CV'Access,
715 Single_RTS_Lock'Access, Rel_Time, Timedout, Result);
717 Cond_Timed_Wait (Self_ID.Common.LL.CV'Access,
718 Self_ID.Common.LL.L'Access, Rel_Time, Timedout, Result);
721 exit when Abs_Time <= Monotonic_Clock;
723 Rel_Time := Abs_Time - Monotonic_Clock;
726 Self_ID.Common.State := Runnable;
736 SSL.Abort_Undefer.all;
743 procedure Wakeup (T : Task_ID; Reason : System.Tasking.Task_States) is
745 Cond_Signal (T.Common.LL.CV'Access);
752 procedure Yield (Do_Yield : Boolean := True) is
763 type Prio_Array_Type is array (System.Any_Priority) of Integer;
764 pragma Atomic_Components (Prio_Array_Type);
766 Prio_Array : Prio_Array_Type;
767 -- Global array containing the id of the currently running task for
770 -- Note: we assume that we are on a single processor with run-til-blocked
773 procedure Set_Priority
775 Prio : System.Any_Priority;
776 Loss_Of_Inheritance : Boolean := False)
779 Array_Item : Integer;
782 Res := SetThreadPriority
783 (T.Common.LL.Thread, Interfaces.C.int (Underlying_Priorities (Prio)));
784 pragma Assert (Res = True);
786 -- ??? Work around a bug in NT 4.0 SP3 scheduler
787 -- It looks like when a task with Thread_Priority_Idle (using RT class)
788 -- never reaches its time slice (e.g by doing multiple and simple RV,
789 -- see CXD8002), the scheduler never gives higher priority task a
791 -- Note that this works fine on NT 4.0 SP1
793 if Time_Slice_Val = 0
794 and then Underlying_Priorities (Prio) = Thread_Priority_Idle
795 and then Loss_Of_Inheritance
800 if FIFO_Within_Priorities then
802 -- Annex D requirement [RM D.2.2 par. 9]:
803 -- If the task drops its priority due to the loss of inherited
804 -- priority, it is added at the head of the ready queue for its
805 -- new active priority.
807 if Loss_Of_Inheritance
808 and then Prio < T.Common.Current_Priority
810 Array_Item := Prio_Array (T.Common.Base_Priority) + 1;
811 Prio_Array (T.Common.Base_Priority) := Array_Item;
814 -- Let some processes a chance to arrive
818 -- Then wait for our turn to proceed
820 exit when Array_Item = Prio_Array (T.Common.Base_Priority)
821 or else Prio_Array (T.Common.Base_Priority) = 1;
824 Prio_Array (T.Common.Base_Priority) :=
825 Prio_Array (T.Common.Base_Priority) - 1;
829 T.Common.Current_Priority := Prio;
836 function Get_Priority (T : Task_ID) return System.Any_Priority is
838 return T.Common.Current_Priority;
845 -- There were two paths were we needed to call Enter_Task :
846 -- 1) from System.Task_Primitives.Operations.Initialize
847 -- 2) from System.Tasking.Stages.Task_Wrapper
849 -- The thread initialisation has to be done only for the first case.
851 -- This is because the GetCurrentThread NT call does not return the
852 -- real thread handler but only a "pseudo" one. It is not possible to
853 -- release the thread handle and free the system ressources from this
854 -- "pseudo" handle. So we really want to keep the real thread handle
855 -- set in System.Task_Primitives.Operations.Create_Task during the
858 procedure Enter_Task (Self_ID : Task_ID) is
859 procedure Init_Float;
860 pragma Import (C, Init_Float, "__gnat_init_float");
861 -- Properly initializes the FPU for x86 systems.
866 Succeeded := TlsSetValue (TlsIndex, To_Address (Self_ID));
867 pragma Assert (Succeeded = True);
870 Self_ID.Common.LL.Thread_Id := GetCurrentThreadId;
874 for J in Known_Tasks'Range loop
875 if Known_Tasks (J) = null then
876 Known_Tasks (J) := Self_ID;
877 Self_ID.Known_Tasks_Index := J;
889 function New_ATCB (Entry_Num : Task_Entry_Index) return Task_ID is
891 return new Ada_Task_Control_Block (Entry_Num);
898 procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is
900 Initialize_Cond (Self_ID.Common.LL.CV'Access);
902 if not Single_Lock then
903 Initialize_Lock (Self_ID.Common.LL.L'Access, ATCB_Level);
913 procedure Create_Task
915 Wrapper : System.Address;
916 Stack_Size : System.Parameters.Size_Type;
917 Priority : System.Any_Priority;
918 Succeeded : out Boolean)
921 TaskId : aliased DWORD;
922 pTaskParameter : System.OS_Interface.PVOID;
925 Entry_Point : PTHREAD_START_ROUTINE;
927 function To_PTHREAD_START_ROUTINE is new
928 Unchecked_Conversion (System.Address, PTHREAD_START_ROUTINE);
931 pTaskParameter := To_Address (T);
933 if Stack_Size = Unspecified_Size then
934 dwStackSize := DWORD (Default_Stack_Size);
936 elsif Stack_Size < Minimum_Stack_Size then
937 dwStackSize := DWORD (Minimum_Stack_Size);
940 dwStackSize := DWORD (Stack_Size);
943 Entry_Point := To_PTHREAD_START_ROUTINE (Wrapper);
945 hTask := CreateThread
950 DWORD (Create_Suspended),
951 TaskId'Unchecked_Access);
953 -- Step 1: Create the thread in blocked mode
959 -- Step 2: set its TCB
961 T.Common.LL.Thread := hTask;
963 -- Step 3: set its priority (child has inherited priority from parent)
965 Set_Priority (T, Priority);
967 -- Step 4: Now, start it for good:
969 Result := ResumeThread (hTask);
970 pragma Assert (Result = 1);
972 Succeeded := Result = 1;
979 procedure Finalize_TCB (T : Task_ID) is
980 Self_ID : Task_ID := T;
984 procedure Free is new
985 Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID);
988 if not Single_Lock then
989 Finalize_Lock (T.Common.LL.L'Access);
992 Finalize_Cond (T.Common.LL.CV'Access);
994 if T.Known_Tasks_Index /= -1 then
995 Known_Tasks (T.Known_Tasks_Index) := null;
998 -- Wait for the thread to terminate then close it. this is needed
999 -- to release system ressources.
1001 Result := WaitForSingleObject (T.Common.LL.Thread, Wait_Infinite);
1002 pragma Assert (Result /= WAIT_FAILED);
1003 Succeeded := CloseHandle (T.Common.LL.Thread);
1004 pragma Assert (Succeeded = True);
1013 procedure Exit_Task is
1022 procedure Abort_Task (T : Task_ID) is
1027 ----------------------
1028 -- Environment_Task --
1029 ----------------------
1031 function Environment_Task return Task_ID is
1033 return Environment_Task_ID;
1034 end Environment_Task;
1040 procedure Lock_RTS is
1042 Write_Lock (Single_RTS_Lock'Access, Global_Lock => True);
1049 procedure Unlock_RTS is
1051 Unlock (Single_RTS_Lock'Access, Global_Lock => True);
1058 procedure Initialize (Environment_Task : Task_ID) is
1061 Environment_Task_ID := Environment_Task;
1063 if Time_Slice_Val = 0 or else FIFO_Within_Priorities then
1064 Res := OS_Interface.SetPriorityClass
1065 (GetCurrentProcess, Realtime_Priority_Class);
1068 TlsIndex := TlsAlloc;
1070 -- Initialize the lock used to synchronize chain of all ATCBs.
1072 Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
1074 Environment_Task.Common.LL.Thread := GetCurrentThread;
1075 Enter_Task (Environment_Task);
1077 -- Create a free ATCB for use on the Fake_ATCB_List
1079 Next_Fake_ATCB := new Fake_ATCB;
1082 ---------------------
1083 -- Monotonic_Clock --
1084 ---------------------
1086 function Monotonic_Clock return Duration
1087 renames System.OS_Primitives.Monotonic_Clock;
1093 function RT_Resolution return Duration is
1095 return 0.000_001; -- 1 micro-second
1102 -- Dummy versions. The only currently working versions is for solaris
1105 function Check_Exit (Self_ID : ST.Task_ID) return Boolean is
1110 --------------------
1111 -- Check_No_Locks --
1112 --------------------
1114 function Check_No_Locks (Self_ID : ST.Task_ID) return Boolean is
1123 function Suspend_Task
1125 Thread_Self : Thread_Id) return Boolean is
1127 if T.Common.LL.Thread /= Thread_Self then
1128 return SuspendThread (T.Common.LL.Thread) = NO_ERROR;
1138 function Resume_Task
1140 Thread_Self : Thread_Id) return Boolean is
1142 if T.Common.LL.Thread /= Thread_Self then
1143 return ResumeThread (T.Common.LL.Thread) = NO_ERROR;
1149 end System.Task_Primitives.Operations;