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-2012, 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 package body System.Task_Primitives.Operations is
44 use System.Parameters;
46 pragma Warnings (Off);
47 -- Turn off warnings since so many unreferenced parameters
55 procedure Set (Self_Id : Task_Id);
57 -- Set the self id for the current task
61 package body Specific is
63 procedure Set (Self_Id : Task_Id) is
69 -- The body of this package is target specific
71 ----------------------------------
72 -- ATCB allocation/deallocation --
73 ----------------------------------
75 package body ATCB_Allocation is separate;
76 -- The body of this package is shared across several targets
82 procedure Abort_Task (T : Task_Id) is
91 function Check_Exit (Self_ID : ST.Task_Id) return Boolean is
100 function Check_No_Locks (Self_ID : ST.Task_Id) return Boolean is
109 function Continue_Task (T : ST.Task_Id) return Boolean is
118 function Current_State (S : Suspension_Object) return Boolean is
123 ----------------------
124 -- Environment_Task --
125 ----------------------
127 function Environment_Task return Task_Id is
130 end Environment_Task;
136 procedure Create_Task
138 Wrapper : System.Address;
139 Stack_Size : System.Parameters.Size_Type;
140 Priority : System.Any_Priority;
141 Succeeded : out Boolean)
151 procedure Enter_Task (Self_ID : Task_Id) is
160 procedure Exit_Task is
169 procedure Finalize (S : in out Suspension_Object) is
178 procedure Finalize_Lock (L : not null access Lock) is
183 procedure Finalize_Lock (L : not null access RTS_Lock) is
192 procedure Finalize_TCB (T : Task_Id) is
201 function Get_Priority (T : Task_Id) return System.Any_Priority is
210 function Get_Thread_Id (T : ST.Task_Id) return OSI.Thread_Id is
212 return OSI.Thread_Id (T.Common.LL.Thread);
219 procedure Initialize (Environment_Task : Task_Id) is
220 No_Tasking : Boolean;
222 raise Program_Error with "tasking not implemented on this configuration";
225 procedure Initialize (S : in out Suspension_Object) is
230 ---------------------
231 -- Initialize_Lock --
232 ---------------------
234 procedure Initialize_Lock
235 (Prio : System.Any_Priority;
236 L : not null access Lock)
242 procedure Initialize_Lock
243 (L : not null access RTS_Lock; Level : Lock_Level) is
252 procedure Initialize_TCB (Self_ID : Task_Id; Succeeded : out Boolean) is
261 function Is_Valid_Task return Boolean is
270 procedure Lock_RTS is
275 ---------------------
276 -- Monotonic_Clock --
277 ---------------------
279 function Monotonic_Clock return Duration is
289 (L : not null access Lock;
290 Ceiling_Violation : out Boolean)
293 Ceiling_Violation := False;
296 -----------------------------
297 -- Register_Foreign_Thread --
298 -----------------------------
300 function Register_Foreign_Thread return Task_Id is
303 end Register_Foreign_Thread;
311 Thread_Self : OSI.Thread_Id) return Boolean
321 function RT_Resolution return Duration is
330 function Self return Task_Id is
339 procedure Set_Ceiling
340 (L : not null access Lock;
341 Prio : System.Any_Priority)
351 procedure Set_False (S : in out Suspension_Object) is
360 procedure Set_Priority
362 Prio : System.Any_Priority;
363 Loss_Of_Inheritance : Boolean := False)
369 -----------------------
370 -- Set_Task_Affinity --
371 -----------------------
373 procedure Set_Task_Affinity (T : ST.Task_Id) is
376 end Set_Task_Affinity;
382 procedure Set_True (S : in out Suspension_Object) is
391 procedure Sleep (Self_ID : Task_Id; Reason : System.Tasking.Task_States) is
400 procedure Stack_Guard (T : ST.Task_Id; On : Boolean) is
409 function Suspend_Task
411 Thread_Self : OSI.Thread_Id) return Boolean
421 procedure Stop_All_Tasks is
430 function Stop_Task (T : ST.Task_Id) return Boolean is
431 pragma Unreferenced (T);
436 ------------------------
437 -- Suspend_Until_True --
438 ------------------------
440 procedure Suspend_Until_True (S : in out Suspension_Object) is
443 end Suspend_Until_True;
449 procedure Timed_Delay
452 Mode : ST.Delay_Modes)
462 procedure Timed_Sleep
465 Mode : ST.Delay_Modes;
466 Reason : System.Tasking.Task_States;
467 Timedout : out Boolean;
468 Yielded : out Boolean)
479 procedure Unlock (L : not null access Lock) is
485 (L : not null access RTS_Lock;
486 Global_Lock : Boolean := False)
492 procedure Unlock (T : Task_Id) is
501 procedure Unlock_RTS is
509 procedure Wakeup (T : Task_Id; Reason : System.Tasking.Task_States) is
519 (L : not null access Lock;
520 Ceiling_Violation : out Boolean)
523 Ceiling_Violation := False;
527 (L : not null access RTS_Lock;
528 Global_Lock : Boolean := False)
534 procedure Write_Lock (T : Task_Id) is
543 procedure Yield (Do_Yield : Boolean := True) is
548 end System.Task_Primitives.Operations;