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-2009, 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 no tasking 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 System.Error_Reporting;
43 package body System.Task_Primitives.Operations is
46 use System.Parameters;
48 pragma Warnings (Off);
49 -- Turn off warnings since so many unreferenced parameters
55 procedure Abort_Task (T : Task_Id) is
64 function Check_Exit (Self_ID : ST.Task_Id) return Boolean is
73 function Check_No_Locks (Self_ID : ST.Task_Id) return Boolean is
82 function Continue_Task (T : ST.Task_Id) return Boolean is
91 function Current_State (S : Suspension_Object) return Boolean is
96 ----------------------
97 -- Environment_Task --
98 ----------------------
100 function Environment_Task return Task_Id is
103 end Environment_Task;
109 procedure Create_Task
111 Wrapper : System.Address;
112 Stack_Size : System.Parameters.Size_Type;
113 Priority : System.Any_Priority;
114 Succeeded : out Boolean)
124 procedure Enter_Task (Self_ID : Task_Id) is
133 procedure Exit_Task is
142 procedure Finalize (S : in out Suspension_Object) is
151 procedure Finalize_Lock (L : not null access Lock) is
156 procedure Finalize_Lock (L : not null access RTS_Lock) is
165 procedure Finalize_TCB (T : Task_Id) is
174 function Get_Priority (T : Task_Id) return System.Any_Priority is
183 function Get_Thread_Id (T : ST.Task_Id) return OSI.Thread_Id is
185 return OSI.Thread_Id (T.Common.LL.Thread);
192 procedure Initialize (Environment_Task : Task_Id) is
193 No_Tasking : Boolean;
196 System.Error_Reporting.Shutdown
197 ("Tasking not implemented on this configuration");
200 procedure Initialize (S : in out Suspension_Object) is
205 ---------------------
206 -- Initialize_Lock --
207 ---------------------
209 procedure Initialize_Lock
210 (Prio : System.Any_Priority;
211 L : not null access Lock)
217 procedure Initialize_Lock
218 (L : not null access RTS_Lock; Level : Lock_Level) is
227 procedure Initialize_TCB (Self_ID : Task_Id; Succeeded : out Boolean) is
236 function Is_Valid_Task return Boolean is
245 procedure Lock_RTS is
250 ---------------------
251 -- Monotonic_Clock --
252 ---------------------
254 function Monotonic_Clock return Duration is
263 function New_ATCB (Entry_Num : Task_Entry_Index) return Task_Id is
265 return new Ada_Task_Control_Block (Entry_Num);
273 (L : not null access Lock;
274 Ceiling_Violation : out Boolean)
277 Ceiling_Violation := False;
280 -----------------------------
281 -- Register_Foreign_Thread --
282 -----------------------------
284 function Register_Foreign_Thread return Task_Id is
287 end Register_Foreign_Thread;
295 Thread_Self : OSI.Thread_Id) return Boolean
305 function RT_Resolution return Duration is
314 function Self return Task_Id is
323 procedure Set_Ceiling
324 (L : not null access Lock;
325 Prio : System.Any_Priority)
335 procedure Set_False (S : in out Suspension_Object) is
344 procedure Set_Priority
346 Prio : System.Any_Priority;
347 Loss_Of_Inheritance : Boolean := False)
357 procedure Set_True (S : in out Suspension_Object) is
366 procedure Sleep (Self_ID : Task_Id; Reason : System.Tasking.Task_States) is
375 procedure Stack_Guard (T : ST.Task_Id; On : Boolean) is
384 function Suspend_Task
386 Thread_Self : OSI.Thread_Id) return Boolean
396 procedure Stop_All_Tasks is
405 function Stop_Task (T : ST.Task_Id) return Boolean is
406 pragma Unreferenced (T);
411 ------------------------
412 -- Suspend_Until_True --
413 ------------------------
415 procedure Suspend_Until_True (S : in out Suspension_Object) is
418 end Suspend_Until_True;
424 procedure Timed_Delay
427 Mode : ST.Delay_Modes)
437 procedure Timed_Sleep
440 Mode : ST.Delay_Modes;
441 Reason : System.Tasking.Task_States;
442 Timedout : out Boolean;
443 Yielded : out Boolean)
454 procedure Unlock (L : not null access Lock) is
460 (L : not null access RTS_Lock;
461 Global_Lock : Boolean := False)
467 procedure Unlock (T : Task_Id) is
476 procedure Unlock_RTS is
484 procedure Wakeup (T : Task_Id; Reason : System.Tasking.Task_States) is
494 (L : not null access Lock;
495 Ceiling_Violation : out Boolean)
498 Ceiling_Violation := False;
502 (L : not null access RTS_Lock;
503 Global_Lock : Boolean := False)
509 procedure Write_Lock (T : Task_Id) is
518 procedure Yield (Do_Yield : Boolean := True) is
523 end System.Task_Primitives.Operations;