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-2001, 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. in cooperation with Florida --
33 -- State University (http://www.gnat.com). --
35 ------------------------------------------------------------------------------
37 -- This is a NT (native) version of this package.
39 -- This package contains all the GNULL primitives that interface directly
40 -- with the underlying OS.
43 -- Turn off polling, we do not want ATC polling to take place during
44 -- tasking operations. It causes infinite loops and other problems.
46 with System.Tasking.Debug;
47 -- used for Known_Tasks
53 with Interfaces.C.Strings;
56 with System.OS_Interface;
57 -- used for various type, constant, and operations
59 with System.Parameters;
63 -- used for Ada_Task_Control_Block
66 with System.Soft_Links;
67 -- used for Defer/Undefer_Abort
68 -- to initialize TSD for a C thread, in function Self
70 -- Note that we do not use System.Tasking.Initialization directly since
71 -- this is a higher level package that we shouldn't depend on. For example
72 -- when using the restricted run time, it is replaced by
73 -- System.Tasking.Restricted.Initialization
75 with System.OS_Primitives;
76 -- used for Delay_Modes
78 with System.Task_Info;
79 -- used for Unspecified_Task_Info
81 with Unchecked_Conversion;
82 with Unchecked_Deallocation;
84 package body System.Task_Primitives.Operations is
86 use System.Tasking.Debug;
89 use Interfaces.C.Strings;
90 use System.OS_Interface;
91 use System.Parameters;
92 use System.OS_Primitives;
94 pragma Linker_Options ("-Xlinker --stack=0x800000,0x1000");
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 All_Tasks_L : aliased System.Task_Primitives.RTS_Lock;
106 -- See comments on locking rules in System.Tasking (spec).
108 Time_Slice_Val : Integer;
109 pragma Import (C, Time_Slice_Val, "__gl_time_slice_val");
111 Dispatching_Policy : Character;
112 pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
114 FIFO_Within_Priorities : constant Boolean := Dispatching_Policy = 'F';
115 -- Indicates whether FIFO_Within_Priorities is set.
117 ---------------------------------
118 -- Foreign Threads Detection --
119 ---------------------------------
121 -- The following are used to allow the Self function to
122 -- automatically generate ATCB's for C threads that happen to call
123 -- Ada procedure, which in turn happen to call the Ada run-time system.
126 type Fake_ATCB_Ptr is access Fake_ATCB;
127 type Fake_ATCB is record
128 Stack_Base : Interfaces.C.unsigned := 0;
129 -- A value of zero indicates the node is not in use.
130 Next : Fake_ATCB_Ptr;
131 Real_ATCB : aliased Ada_Task_Control_Block (0);
134 Fake_ATCB_List : Fake_ATCB_Ptr;
135 -- A linear linked list.
136 -- The list is protected by All_Tasks_L;
137 -- Nodes are added to this list from the front.
138 -- Once a node is added to this list, it is never removed.
140 Fake_Task_Elaborated : aliased Boolean := True;
141 -- Used to identified fake tasks (i.e., non-Ada Threads).
143 Next_Fake_ATCB : Fake_ATCB_Ptr;
144 -- Used to allocate one Fake_ATCB in advance. See comment in New_Fake_ATCB
146 ---------------------------------
147 -- Support for New_Fake_ATCB --
148 ---------------------------------
150 function New_Fake_ATCB return Task_ID;
151 -- Allocate and Initialize a new ATCB. This code can safely be called from
152 -- a foreign thread, as it doesn't access implicitely or explicitely
153 -- "self" before having initialized the new ATCB.
155 ------------------------------------
156 -- The thread local storage index --
157 ------------------------------------
160 pragma Export (Ada, TlsIndex);
161 -- To ensure that this variable won't be local to this package, since
162 -- in some cases, inlining forces this variable to be global anyway.
164 ----------------------------------
165 -- Utility Conversion Functions --
166 ----------------------------------
168 function To_Task_Id is new Unchecked_Conversion (System.Address, Task_ID);
170 function To_Address is new Unchecked_Conversion (Task_ID, System.Address);
176 function New_Fake_ATCB return Task_ID is
178 P, Q : Fake_ATCB_Ptr;
183 -- This section is ticklish.
184 -- We dare not call anything that might require an ATCB, until
185 -- we have the new ATCB in place.
187 Write_Lock (All_Tasks_L'Access);
192 if P.Stack_Base = 0 then
201 -- Create a new ATCB with zero entries.
203 Self_ID := Next_Fake_ATCB.Real_ATCB'Access;
204 Next_Fake_ATCB.Stack_Base := 1;
205 Next_Fake_ATCB.Next := Fake_ATCB_List;
206 Fake_ATCB_List := Next_Fake_ATCB;
207 Next_Fake_ATCB := null;
210 -- Reuse an existing fake ATCB.
212 Self_ID := Q.Real_ATCB'Access;
216 -- Record this as the Task_ID for the current thread.
218 Self_ID.Common.LL.Thread := GetCurrentThread;
220 Res := TlsSetValue (TlsIndex, To_Address (Self_ID));
221 pragma Assert (Res = True);
223 -- Do the standard initializations
225 System.Tasking.Initialize_ATCB
226 (Self_ID, null, Null_Address, Null_Task, Fake_Task_Elaborated'Access,
227 System.Priority'First, Task_Info.Unspecified_Task_Info, 0, Self_ID,
229 pragma Assert (Succeeded);
231 -- Finally, it is safe to use an allocator in this thread.
233 if Next_Fake_ATCB = null then
234 Next_Fake_ATCB := new Fake_ATCB;
237 Self_ID.Master_of_Task := 0;
238 Self_ID.Master_Within := Self_ID.Master_of_Task + 1;
240 for L in Self_ID.Entry_Calls'Range loop
241 Self_ID.Entry_Calls (L).Self := Self_ID;
242 Self_ID.Entry_Calls (L).Level := L;
245 Self_ID.Common.State := Runnable;
246 Self_ID.Awake_Count := 1;
248 -- Since this is not an ordinary Ada task, we will start out undeferred
250 Self_ID.Deferral_Level := 0;
252 System.Soft_Links.Create_TSD (Self_ID.Common.Compiler_Data);
255 -- The following call is commented out to avoid dependence on
256 -- the System.Tasking.Initialization package.
257 -- It seems that if we want Ada.Task_Attributes to work correctly
258 -- for C threads we will need to raise the visibility of this soft
259 -- link to System.Soft_Links.
260 -- We are putting that off until this new functionality is otherwise
262 -- System.Tasking.Initialization.Initialize_Attributes_Link.all (T);
264 -- Must not unlock until Next_ATCB is again allocated.
266 Unlock (All_Tasks_L'Access);
270 ----------------------------------
271 -- Condition Variable Functions --
272 ----------------------------------
274 procedure Initialize_Cond (Cond : access Condition_Variable);
275 -- Initialize given condition variable Cond
277 procedure Finalize_Cond (Cond : access Condition_Variable);
278 -- Finalize given condition variable Cond.
280 procedure Cond_Signal (Cond : access Condition_Variable);
281 -- Signal condition variable Cond
284 (Cond : access Condition_Variable;
285 L : access RTS_Lock);
286 -- Wait on conditional variable Cond, using lock L
288 procedure Cond_Timed_Wait
289 (Cond : access Condition_Variable;
292 Timed_Out : out Boolean;
293 Status : out Integer);
294 -- Do timed wait on condition variable Cond using lock L. The duration
295 -- of the timed wait is given by Rel_Time. When the condition is
296 -- signalled, Timed_Out shows whether or not a time out occurred.
297 -- Status shows whether Cond_Timed_Wait completed successfully.
299 ---------------------
300 -- Initialize_Cond --
301 ---------------------
303 procedure Initialize_Cond (Cond : access Condition_Variable) is
307 hEvent := CreateEvent (null, True, False, Null_Ptr);
308 pragma Assert (hEvent /= 0);
309 Cond.all := Condition_Variable (hEvent);
316 -- No such problem here, DosCloseEventSem has been derived.
317 -- What does such refer to in above comment???
319 procedure Finalize_Cond (Cond : access Condition_Variable) is
323 Result := CloseHandle (HANDLE (Cond.all));
324 pragma Assert (Result = True);
331 procedure Cond_Signal (Cond : access Condition_Variable) is
335 Result := SetEvent (HANDLE (Cond.all));
336 pragma Assert (Result = True);
343 -- Pre-assertion: Cond is posted
346 -- Post-assertion: Cond is posted
350 (Cond : access Condition_Variable;
357 -- Must reset Cond BEFORE L is unlocked.
359 Result_Bool := ResetEvent (HANDLE (Cond.all));
360 pragma Assert (Result_Bool = True);
363 -- No problem if we are interrupted here: if the condition is signaled,
364 -- WaitForSingleObject will simply not block
366 Result := WaitForSingleObject (HANDLE (Cond.all), Wait_Infinite);
367 pragma Assert (Result = 0);
372 ---------------------
373 -- Cond_Timed_Wait --
374 ---------------------
376 -- Pre-assertion: Cond is posted
379 -- Post-assertion: Cond is posted
382 procedure Cond_Timed_Wait
383 (Cond : access Condition_Variable;
386 Timed_Out : out Boolean;
387 Status : out Integer)
392 Int_Rel_Time : DWORD;
396 -- Must reset Cond BEFORE L is unlocked.
398 Result := ResetEvent (HANDLE (Cond.all));
399 pragma Assert (Result = True);
402 -- No problem if we are interrupted here: if the condition is signaled,
403 -- WaitForSingleObject will simply not block
405 if Rel_Time <= 0.0 then
408 Int_Rel_Time := DWORD (Rel_Time);
409 Time_Out := Int_Rel_Time * 1000 +
410 DWORD ((Rel_Time - Duration (Int_Rel_Time)) * 1000.0);
411 Wait_Result := WaitForSingleObject (HANDLE (Cond.all), Time_Out);
413 if Wait_Result = WAIT_TIMEOUT then
423 -- Ensure post-condition
426 Result := SetEvent (HANDLE (Cond.all));
427 pragma Assert (Result = True);
430 Status := Integer (Wait_Result);
437 -- The underlying thread system sets a guard page at the
438 -- bottom of a thread stack, so nothing is needed.
439 -- ??? Check the comment above
441 procedure Stack_Guard (T : ST.Task_ID; On : Boolean) is
450 function Get_Thread_Id (T : ST.Task_ID) return OSI.Thread_Id is
452 return T.Common.LL.Thread;
459 function Self return Task_ID is
463 Self_Id := To_Task_Id (TlsGetValue (TlsIndex));
465 if Self_Id = null then
466 return New_Fake_ATCB;
472 ---------------------
473 -- Initialize_Lock --
474 ---------------------
476 -- Note: mutexes and cond_variables needed per-task basis are
477 -- initialized in Intialize_TCB and the Storage_Error is handled.
478 -- Other mutexes (such as All_Tasks_Lock, Memory_Lock...) used in
479 -- the RTS is initialized before any status change of RTS.
480 -- Therefore raising Storage_Error in the following routines
481 -- should be able to be handled safely.
483 procedure Initialize_Lock
484 (Prio : System.Any_Priority;
487 InitializeCriticalSection (L.Mutex'Access);
488 L.Owner_Priority := 0;
492 procedure Initialize_Lock (L : access RTS_Lock; Level : Lock_Level) is
494 InitializeCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access);
501 procedure Finalize_Lock (L : access Lock) is
503 DeleteCriticalSection (L.Mutex'Access);
506 procedure Finalize_Lock (L : access RTS_Lock) is
508 DeleteCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access);
515 procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is
517 L.Owner_Priority := Get_Priority (Self);
519 if L.Priority < L.Owner_Priority then
520 Ceiling_Violation := True;
524 EnterCriticalSection (L.Mutex'Access);
526 Ceiling_Violation := False;
529 procedure Write_Lock (L : access RTS_Lock) is
531 EnterCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access);
534 procedure Write_Lock (T : Task_ID) is
537 (CRITICAL_SECTION (T.Common.LL.L)'Unrestricted_Access);
544 procedure Read_Lock (L : access Lock; Ceiling_Violation : out Boolean) is
546 Write_Lock (L, Ceiling_Violation);
553 procedure Unlock (L : access Lock) is
555 LeaveCriticalSection (L.Mutex'Access);
558 procedure Unlock (L : access RTS_Lock) is
560 LeaveCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access);
563 procedure Unlock (T : Task_ID) is
566 (CRITICAL_SECTION (T.Common.LL.L)'Unrestricted_Access);
575 Reason : System.Tasking.Task_States) is
577 pragma Assert (Self_ID = Self);
579 Cond_Wait (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access);
581 if Self_ID.Deferral_Level = 0
582 and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level
585 raise Standard'Abort_Signal;
593 -- This is for use within the run-time system, so abort is
594 -- assumed to be already deferred, and the caller should be
595 -- holding its own ATCB lock.
597 procedure Timed_Sleep
600 Mode : ST.Delay_Modes;
601 Reason : System.Tasking.Task_States;
602 Timedout : out Boolean;
603 Yielded : out Boolean)
605 Check_Time : constant Duration := Monotonic_Clock;
610 Local_Timedout : Boolean;
616 if Mode = Relative then
618 Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time;
620 Rel_Time := Time - Check_Time;
624 if Rel_Time > 0.0 then
626 exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level
627 or else Self_ID.Pending_Priority_Change;
629 Cond_Timed_Wait (Self_ID.Common.LL.CV'Access,
630 Self_ID.Common.LL.L'Access, Rel_Time, Local_Timedout, Result);
632 exit when Abs_Time <= Monotonic_Clock;
634 if not Local_Timedout then
635 -- somebody may have called Wakeup for us
640 Rel_Time := Abs_Time - Monotonic_Clock;
649 procedure Timed_Delay
652 Mode : ST.Delay_Modes)
654 Check_Time : constant Duration := Monotonic_Clock;
661 -- Only the little window between deferring abort and
662 -- locking Self_ID is the reason we need to
663 -- check for pending abort and priority change below! :(
666 Write_Lock (Self_ID);
668 if Mode = Relative then
670 Abs_Time := Time + Check_Time;
672 Rel_Time := Time - Check_Time;
676 if Rel_Time > 0.0 then
677 Self_ID.Common.State := Delay_Sleep;
680 if Self_ID.Pending_Priority_Change then
681 Self_ID.Pending_Priority_Change := False;
682 Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority;
683 Set_Priority (Self_ID, Self_ID.Common.Base_Priority);
686 exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level;
688 Cond_Timed_Wait (Self_ID.Common.LL.CV'Access,
689 Self_ID.Common.LL.L'Access, Rel_Time, Timedout, Result);
691 exit when Abs_Time <= Monotonic_Clock;
693 Rel_Time := Abs_Time - Monotonic_Clock;
696 Self_ID.Common.State := Runnable;
701 SSL.Abort_Undefer.all;
708 procedure Wakeup (T : Task_ID; Reason : System.Tasking.Task_States) is
710 Cond_Signal (T.Common.LL.CV'Access);
717 procedure Yield (Do_Yield : Boolean := True) is
728 type Prio_Array_Type is array (System.Any_Priority) of Integer;
729 pragma Atomic_Components (Prio_Array_Type);
731 Prio_Array : Prio_Array_Type;
732 -- Global array containing the id of the currently running task for
735 -- Note: we assume that we are on a single processor with run-til-blocked
738 procedure Set_Priority
740 Prio : System.Any_Priority;
741 Loss_Of_Inheritance : Boolean := False)
744 Array_Item : Integer;
747 Res := SetThreadPriority
748 (T.Common.LL.Thread, Interfaces.C.int (Underlying_Priorities (Prio)));
749 pragma Assert (Res = True);
751 -- ??? Work around a bug in NT 4.0 SP3 scheduler
752 -- It looks like when a task with Thread_Priority_Idle (using RT class)
753 -- never reaches its time slice (e.g by doing multiple and simple RV,
754 -- see CXD8002), the scheduler never gives higher priority task a
756 -- Note that this works fine on NT 4.0 SP1
758 if Time_Slice_Val = 0
759 and then Underlying_Priorities (Prio) = Thread_Priority_Idle
760 and then Loss_Of_Inheritance
765 if FIFO_Within_Priorities then
767 -- Annex D requirement [RM D.2.2 par. 9]:
768 -- If the task drops its priority due to the loss of inherited
769 -- priority, it is added at the head of the ready queue for its
770 -- new active priority.
772 if Loss_Of_Inheritance
773 and then Prio < T.Common.Current_Priority
775 Array_Item := Prio_Array (T.Common.Base_Priority) + 1;
776 Prio_Array (T.Common.Base_Priority) := Array_Item;
779 -- Let some processes a chance to arrive
783 -- Then wait for our turn to proceed
785 exit when Array_Item = Prio_Array (T.Common.Base_Priority)
786 or else Prio_Array (T.Common.Base_Priority) = 1;
789 Prio_Array (T.Common.Base_Priority) :=
790 Prio_Array (T.Common.Base_Priority) - 1;
794 T.Common.Current_Priority := Prio;
801 function Get_Priority (T : Task_ID) return System.Any_Priority is
803 return T.Common.Current_Priority;
810 -- There were two paths were we needed to call Enter_Task :
811 -- 1) from System.Task_Primitives.Operations.Initialize
812 -- 2) from System.Tasking.Stages.Task_Wrapper
814 -- The thread initialisation has to be done only for the first case.
816 -- This is because the GetCurrentThread NT call does not return the
817 -- real thread handler but only a "pseudo" one. It is not possible to
818 -- release the thread handle and free the system ressources from this
819 -- "pseudo" handle. So we really want to keep the real thread handle
820 -- set in System.Task_Primitives.Operations.Create_Task during the
823 procedure Enter_Task (Self_ID : Task_ID) is
824 procedure Init_Float;
825 pragma Import (C, Init_Float, "__gnat_init_float");
826 -- Properly initializes the FPU for x86 systems.
831 Succeeded := TlsSetValue (TlsIndex, To_Address (Self_ID));
832 pragma Assert (Succeeded = True);
835 Self_ID.Common.LL.Thread_Id := GetCurrentThreadId;
839 for J in Known_Tasks'Range loop
840 if Known_Tasks (J) = null then
841 Known_Tasks (J) := Self_ID;
842 Self_ID.Known_Tasks_Index := J;
847 Unlock_All_Tasks_List;
854 function New_ATCB (Entry_Num : Task_Entry_Index) return Task_ID is
856 return new Ada_Task_Control_Block (Entry_Num);
859 ----------------------
861 ----------------------
863 procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is
865 Initialize_Cond (Self_ID.Common.LL.CV'Access);
866 Initialize_Lock (Self_ID.Common.LL.L'Access, ATCB_Level);
874 procedure Create_Task
876 Wrapper : System.Address;
877 Stack_Size : System.Parameters.Size_Type;
878 Priority : System.Any_Priority;
879 Succeeded : out Boolean)
882 TaskId : aliased DWORD;
884 -- ??? The fact that we can't use PVOID because the compiler
885 -- gives a "PVOID is not visible" error is a GNAT bug.
886 -- The strange thing is that the file compiles fine during a regular
889 pTaskParameter : System.OS_Interface.PVOID;
892 Entry_Point : PTHREAD_START_ROUTINE;
894 function To_PTHREAD_START_ROUTINE is new
895 Unchecked_Conversion (System.Address, PTHREAD_START_ROUTINE);
898 pTaskParameter := To_Address (T);
900 if Stack_Size = Unspecified_Size then
901 dwStackSize := DWORD (Default_Stack_Size);
903 elsif Stack_Size < Minimum_Stack_Size then
904 dwStackSize := DWORD (Minimum_Stack_Size);
907 dwStackSize := DWORD (Stack_Size);
910 Entry_Point := To_PTHREAD_START_ROUTINE (Wrapper);
912 hTask := CreateThread
917 DWORD (Create_Suspended),
918 TaskId'Unchecked_Access);
920 -- Step 1: Create the thread in blocked mode
926 -- Step 2: set its TCB
928 T.Common.LL.Thread := hTask;
930 -- Step 3: set its priority (child has inherited priority from parent)
932 Set_Priority (T, Priority);
934 -- Step 4: Now, start it for good:
936 Result := ResumeThread (hTask);
937 pragma Assert (Result = 1);
939 Succeeded := Result = 1;
946 procedure Finalize_TCB (T : Task_ID) is
947 Self_ID : Task_ID := T;
951 procedure Free is new
952 Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID);
955 Finalize_Lock (T.Common.LL.L'Access);
956 Finalize_Cond (T.Common.LL.CV'Access);
958 if T.Known_Tasks_Index /= -1 then
959 Known_Tasks (T.Known_Tasks_Index) := null;
962 -- Wait for the thread to terminate then close it. this is needed
963 -- to release system ressources.
965 Result := WaitForSingleObject (T.Common.LL.Thread, Wait_Infinite);
966 pragma Assert (Result /= WAIT_FAILED);
967 Succeeded := CloseHandle (T.Common.LL.Thread);
968 pragma Assert (Succeeded = True);
977 procedure Exit_Task is
986 procedure Abort_Task (T : Task_ID) is
991 ----------------------
992 -- Environment_Task --
993 ----------------------
995 function Environment_Task return Task_ID is
997 return Environment_Task_ID;
998 end Environment_Task;
1000 -------------------------
1001 -- Lock_All_Tasks_List --
1002 -------------------------
1004 procedure Lock_All_Tasks_List is
1006 Write_Lock (All_Tasks_L'Access);
1007 end Lock_All_Tasks_List;
1009 ---------------------------
1010 -- Unlock_All_Tasks_List --
1011 ---------------------------
1013 procedure Unlock_All_Tasks_List is
1015 Unlock (All_Tasks_L'Access);
1016 end Unlock_All_Tasks_List;
1022 procedure Initialize (Environment_Task : Task_ID) is
1025 Environment_Task_ID := Environment_Task;
1027 if Time_Slice_Val = 0 or else FIFO_Within_Priorities then
1028 Res := OS_Interface.SetPriorityClass
1029 (GetCurrentProcess, Realtime_Priority_Class);
1032 TlsIndex := TlsAlloc;
1034 -- Initialize the lock used to synchronize chain of all ATCBs.
1036 Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level);
1038 Environment_Task.Common.LL.Thread := GetCurrentThread;
1039 Enter_Task (Environment_Task);
1041 -- Create a free ATCB for use on the Fake_ATCB_List
1043 Next_Fake_ATCB := new Fake_ATCB;
1046 ---------------------
1047 -- Monotonic_Clock --
1048 ---------------------
1050 function Monotonic_Clock return Duration
1051 renames System.OS_Primitives.Monotonic_Clock;
1057 function RT_Resolution return Duration is
1059 return 0.000_001; -- 1 micro-second
1066 -- Dummy versions. The only currently working versions is for solaris
1069 function Check_Exit (Self_ID : ST.Task_ID) return Boolean is
1074 --------------------
1075 -- Check_No_Locks --
1076 --------------------
1078 function Check_No_Locks (Self_ID : ST.Task_ID) return Boolean is
1087 function Suspend_Task
1089 Thread_Self : Thread_Id) return Boolean is
1091 if T.Common.LL.Thread /= Thread_Self then
1092 return SuspendThread (T.Common.LL.Thread) = NO_ERROR;
1102 function Resume_Task
1104 Thread_Self : Thread_Id) return Boolean is
1106 if T.Common.LL.Thread /= Thread_Self then
1107 return ResumeThread (T.Common.LL.Thread) = NO_ERROR;
1113 end System.Task_Primitives.Operations;