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-2008, Free Software Foundation, Inc. --
11 -- GNARL is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNARL; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNARL was developed by the GNARL team at Florida State University. --
30 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
32 ------------------------------------------------------------------------------
34 -- This is a no tasking version of this package
36 -- This package contains all the GNULL primitives that interface directly with
40 -- Turn off polling, we do not want ATC polling to take place during tasking
41 -- operations. It causes infinite loops and other problems.
43 with System.Error_Reporting;
45 package body System.Task_Primitives.Operations is
48 use System.Parameters;
50 pragma Warnings (Off);
51 -- Turn off warnings since so many unreferenced parameters
57 procedure Abort_Task (T : Task_Id) is
66 function Check_Exit (Self_ID : ST.Task_Id) return Boolean is
75 function Check_No_Locks (Self_ID : ST.Task_Id) return Boolean is
84 function Continue_Task (T : ST.Task_Id) return Boolean is
93 function Current_State (S : Suspension_Object) return Boolean is
98 ----------------------
99 -- Environment_Task --
100 ----------------------
102 function Environment_Task return Task_Id is
105 end Environment_Task;
111 procedure Create_Task
113 Wrapper : System.Address;
114 Stack_Size : System.Parameters.Size_Type;
115 Priority : System.Any_Priority;
116 Succeeded : out Boolean)
126 procedure Enter_Task (Self_ID : Task_Id) is
135 procedure Exit_Task is
144 procedure Finalize (S : in out Suspension_Object) is
153 procedure Finalize_Lock (L : not null access Lock) is
158 procedure Finalize_Lock (L : not null access RTS_Lock) is
167 procedure Finalize_TCB (T : Task_Id) is
176 function Get_Priority (T : Task_Id) return System.Any_Priority is
185 function Get_Thread_Id (T : ST.Task_Id) return OSI.Thread_Id is
187 return OSI.Thread_Id (T.Common.LL.Thread);
194 procedure Initialize (Environment_Task : Task_Id) is
195 No_Tasking : Boolean;
198 System.Error_Reporting.Shutdown
199 ("Tasking not implemented on this configuration");
202 procedure Initialize (S : in out Suspension_Object) is
207 ---------------------
208 -- Initialize_Lock --
209 ---------------------
211 procedure Initialize_Lock
212 (Prio : System.Any_Priority;
213 L : not null access Lock)
219 procedure Initialize_Lock
220 (L : not null access RTS_Lock; Level : Lock_Level) is
229 procedure Initialize_TCB (Self_ID : Task_Id; Succeeded : out Boolean) is
238 function Is_Valid_Task return Boolean is
247 procedure Lock_RTS is
252 ---------------------
253 -- Monotonic_Clock --
254 ---------------------
256 function Monotonic_Clock return Duration is
265 function New_ATCB (Entry_Num : Task_Entry_Index) return Task_Id is
267 return new Ada_Task_Control_Block (Entry_Num);
275 (L : not null access Lock;
276 Ceiling_Violation : out Boolean)
279 Ceiling_Violation := False;
282 -----------------------------
283 -- Register_Foreign_Thread --
284 -----------------------------
286 function Register_Foreign_Thread return Task_Id is
289 end Register_Foreign_Thread;
297 Thread_Self : OSI.Thread_Id) return Boolean
307 function RT_Resolution return Duration is
316 function Self return Task_Id is
325 procedure Set_Ceiling
326 (L : not null access Lock;
327 Prio : System.Any_Priority)
337 procedure Set_False (S : in out Suspension_Object) is
346 procedure Set_Priority
348 Prio : System.Any_Priority;
349 Loss_Of_Inheritance : Boolean := False)
359 procedure Set_True (S : in out Suspension_Object) is
368 procedure Sleep (Self_ID : Task_Id; Reason : System.Tasking.Task_States) is
377 procedure Stack_Guard (T : ST.Task_Id; On : Boolean) is
386 function Suspend_Task
388 Thread_Self : OSI.Thread_Id) return Boolean
398 procedure Stop_All_Tasks is
407 function Stop_Task (T : ST.Task_Id) return Boolean is
408 pragma Unreferenced (T);
413 ------------------------
414 -- Suspend_Until_True --
415 ------------------------
417 procedure Suspend_Until_True (S : in out Suspension_Object) is
420 end Suspend_Until_True;
426 procedure Timed_Delay
429 Mode : ST.Delay_Modes)
439 procedure Timed_Sleep
442 Mode : ST.Delay_Modes;
443 Reason : System.Tasking.Task_States;
444 Timedout : out Boolean;
445 Yielded : out Boolean)
456 procedure Unlock (L : not null access Lock) is
462 (L : not null access RTS_Lock;
463 Global_Lock : Boolean := False)
469 procedure Unlock (T : Task_Id) is
478 procedure Unlock_RTS is
486 procedure Wakeup (T : Task_Id; Reason : System.Tasking.Task_States) is
496 (L : not null access Lock;
497 Ceiling_Violation : out Boolean)
500 Ceiling_Violation := False;
504 (L : not null access RTS_Lock;
505 Global_Lock : Boolean := False)
511 procedure Write_Lock (T : Task_Id) is
520 procedure Yield (Do_Yield : Boolean := True) is
525 end System.Task_Primitives.Operations;