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-2018, 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
53 -- Package Specific contains target specific routines, and the body of
54 -- this package is target specific.
57 procedure Set
(Self_Id
: Task_Id
);
59 -- Set the self id for the current task
62 package body Specific
is
68 procedure Set
(Self_Id
: Task_Id
) is
74 ----------------------------------
75 -- ATCB allocation/deallocation --
76 ----------------------------------
78 package body ATCB_Allocation
is separate;
79 -- The body of this package is shared across several targets
85 procedure Abort_Task
(T
: Task_Id
) is
94 function Check_Exit
(Self_ID
: ST
.Task_Id
) return Boolean is
103 function Check_No_Locks
(Self_ID
: ST
.Task_Id
) return Boolean is
112 function Continue_Task
(T
: ST
.Task_Id
) return Boolean is
121 function Current_State
(S
: Suspension_Object
) return Boolean is
126 ----------------------
127 -- Environment_Task --
128 ----------------------
130 function Environment_Task
return Task_Id
is
133 end Environment_Task
;
139 procedure Create_Task
141 Wrapper
: System
.Address
;
142 Stack_Size
: System
.Parameters
.Size_Type
;
143 Priority
: System
.Any_Priority
;
144 Succeeded
: out Boolean)
154 procedure Enter_Task
(Self_ID
: Task_Id
) is
163 procedure Exit_Task
is
172 procedure Finalize
(S
: in out Suspension_Object
) is
181 procedure Finalize_Lock
(L
: not null access Lock
) is
186 procedure Finalize_Lock
(L
: not null access RTS_Lock
) is
195 procedure Finalize_TCB
(T
: Task_Id
) is
204 function Get_Priority
(T
: Task_Id
) return System
.Any_Priority
is
213 function Get_Thread_Id
(T
: ST
.Task_Id
) return OSI
.Thread_Id
is
215 return OSI
.Thread_Id
(T
.Common
.LL
.Thread
);
222 procedure Initialize
(Environment_Task
: Task_Id
) is
223 No_Tasking
: Boolean;
225 raise Program_Error
with "tasking not implemented on this configuration";
228 procedure Initialize
(S
: in out Suspension_Object
) is
233 ---------------------
234 -- Initialize_Lock --
235 ---------------------
237 procedure Initialize_Lock
238 (Prio
: System
.Any_Priority
;
239 L
: not null access Lock
)
245 procedure Initialize_Lock
246 (L
: not null access RTS_Lock
; Level
: Lock_Level
) is
255 procedure Initialize_TCB
(Self_ID
: Task_Id
; Succeeded
: out Boolean) is
264 function Is_Valid_Task
return Boolean is
273 procedure Lock_RTS
is
278 ---------------------
279 -- Monotonic_Clock --
280 ---------------------
282 function Monotonic_Clock
return Duration is
292 (L
: not null access Lock
;
293 Ceiling_Violation
: out Boolean)
296 Ceiling_Violation
:= False;
299 -----------------------------
300 -- Register_Foreign_Thread --
301 -----------------------------
303 function Register_Foreign_Thread
return Task_Id
is
306 end Register_Foreign_Thread
;
314 Thread_Self
: OSI
.Thread_Id
) return Boolean
324 function RT_Resolution
return Duration is
333 function Self
return Task_Id
is
342 procedure Set_Ceiling
343 (L
: not null access Lock
;
344 Prio
: System
.Any_Priority
)
354 procedure Set_False
(S
: in out Suspension_Object
) is
363 procedure Set_Priority
365 Prio
: System
.Any_Priority
;
366 Loss_Of_Inheritance
: Boolean := False)
372 -----------------------
373 -- Set_Task_Affinity --
374 -----------------------
376 procedure Set_Task_Affinity
(T
: ST
.Task_Id
) is
379 end Set_Task_Affinity
;
385 procedure Set_True
(S
: in out Suspension_Object
) is
394 procedure Sleep
(Self_ID
: Task_Id
; Reason
: System
.Tasking
.Task_States
) is
403 procedure Stack_Guard
(T
: ST
.Task_Id
; On
: Boolean) is
412 function Suspend_Task
414 Thread_Self
: OSI
.Thread_Id
) return Boolean
424 procedure Stop_All_Tasks
is
433 function Stop_Task
(T
: ST
.Task_Id
) return Boolean is
434 pragma Unreferenced
(T
);
439 ------------------------
440 -- Suspend_Until_True --
441 ------------------------
443 procedure Suspend_Until_True
(S
: in out Suspension_Object
) is
446 end Suspend_Until_True
;
452 procedure Timed_Delay
455 Mode
: ST
.Delay_Modes
)
465 procedure Timed_Sleep
468 Mode
: ST
.Delay_Modes
;
469 Reason
: System
.Tasking
.Task_States
;
470 Timedout
: out Boolean;
471 Yielded
: out Boolean)
482 procedure Unlock
(L
: not null access Lock
) is
488 (L
: not null access RTS_Lock
;
489 Global_Lock
: Boolean := False)
495 procedure Unlock
(T
: Task_Id
) is
504 procedure Unlock_RTS
is
512 procedure Wakeup
(T
: Task_Id
; Reason
: System
.Tasking
.Task_States
) is
522 (L
: not null access Lock
;
523 Ceiling_Violation
: out Boolean)
526 Ceiling_Violation
:= False;
530 (L
: not null access RTS_Lock
;
531 Global_Lock
: Boolean := False)
537 procedure Write_Lock
(T
: Task_Id
) is
546 procedure Yield
(Do_Yield
: Boolean := True) is
551 end System
.Task_Primitives
.Operations
;