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-2023, 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
37 package body System
.Task_Primitives
.Operations
is
40 use System
.Parameters
;
42 pragma Warnings
(Off
);
43 -- Turn off warnings since so many unreferenced parameters
49 -- Package Specific contains target specific routines, and the body of
50 -- this package is target specific.
53 procedure Set
(Self_Id
: Task_Id
);
55 -- Set the self id for the current task
58 package body Specific
is
64 procedure Set
(Self_Id
: Task_Id
) is
70 ----------------------------------
71 -- ATCB allocation/deallocation --
72 ----------------------------------
74 package body ATCB_Allocation
is separate;
75 -- The body of this package is shared across several targets
81 procedure Abort_Task
(T
: Task_Id
) is
90 function Check_Exit
(Self_ID
: ST
.Task_Id
) return Boolean is
99 function Check_No_Locks
(Self_ID
: ST
.Task_Id
) return Boolean is
108 function Continue_Task
(T
: ST
.Task_Id
) return Boolean is
117 function Current_State
(S
: Suspension_Object
) return Boolean is
122 ----------------------
123 -- Environment_Task --
124 ----------------------
126 function Environment_Task
return Task_Id
is
129 end Environment_Task
;
135 procedure Create_Task
137 Wrapper
: System
.Address
;
138 Stack_Size
: System
.Parameters
.Size_Type
;
139 Priority
: System
.Any_Priority
;
140 Succeeded
: out Boolean)
150 procedure Enter_Task
(Self_ID
: Task_Id
) is
159 procedure Exit_Task
is
168 procedure Finalize
(S
: in out Suspension_Object
) is
177 procedure Finalize_Lock
(L
: not null access Lock
) is
182 procedure Finalize_Lock
(L
: not null access RTS_Lock
) is
191 procedure Finalize_TCB
(T
: Task_Id
) is
200 function Get_Priority
(T
: Task_Id
) return System
.Any_Priority
is
209 function Get_Thread_Id
(T
: ST
.Task_Id
) return OSI
.Thread_Id
is
211 return OSI
.Thread_Id
(T
.Common
.LL
.Thread
);
218 procedure Initialize
(Environment_Task
: Task_Id
) is
219 No_Tasking
: Boolean;
221 raise Program_Error
with "tasking not implemented on this configuration";
224 procedure Initialize
(S
: in out Suspension_Object
) is
229 ---------------------
230 -- Initialize_Lock --
231 ---------------------
233 procedure Initialize_Lock
234 (Prio
: System
.Any_Priority
;
235 L
: not null access Lock
)
241 procedure Initialize_Lock
242 (L
: not null access RTS_Lock
; Level
: Lock_Level
) is
251 procedure Initialize_TCB
(Self_ID
: Task_Id
; Succeeded
: out Boolean) is
260 function Is_Valid_Task
return Boolean is
269 procedure Lock_RTS
is
274 ---------------------
275 -- Monotonic_Clock --
276 ---------------------
278 function Monotonic_Clock
return Duration is
288 (L
: not null access Lock
;
289 Ceiling_Violation
: out Boolean)
292 Ceiling_Violation
:= False;
295 -----------------------------
296 -- Register_Foreign_Thread --
297 -----------------------------
299 function Register_Foreign_Thread
return Task_Id
is
302 end Register_Foreign_Thread
;
310 Thread_Self
: OSI
.Thread_Id
) return Boolean
320 function RT_Resolution
return Duration is
329 function Self
return Task_Id
is
338 procedure Set_Ceiling
339 (L
: not null access Lock
;
340 Prio
: System
.Any_Priority
)
350 procedure Set_False
(S
: in out Suspension_Object
) is
359 procedure Set_Priority
361 Prio
: System
.Any_Priority
;
362 Loss_Of_Inheritance
: Boolean := False)
368 -----------------------
369 -- Set_Task_Affinity --
370 -----------------------
372 procedure Set_Task_Affinity
(T
: ST
.Task_Id
) is
375 end Set_Task_Affinity
;
381 procedure Set_True
(S
: in out Suspension_Object
) is
390 procedure Sleep
(Self_ID
: Task_Id
; Reason
: System
.Tasking
.Task_States
) is
399 procedure Stack_Guard
(T
: ST
.Task_Id
; On
: Boolean) is
408 function Suspend_Task
410 Thread_Self
: OSI
.Thread_Id
) return Boolean
420 procedure Stop_All_Tasks
is
429 function Stop_Task
(T
: ST
.Task_Id
) return Boolean is
430 pragma Unreferenced
(T
);
435 ------------------------
436 -- Suspend_Until_True --
437 ------------------------
439 procedure Suspend_Until_True
(S
: in out Suspension_Object
) is
442 end Suspend_Until_True
;
448 procedure Timed_Delay
451 Mode
: ST
.Delay_Modes
)
461 procedure Timed_Sleep
464 Mode
: ST
.Delay_Modes
;
465 Reason
: System
.Tasking
.Task_States
;
466 Timedout
: out Boolean;
467 Yielded
: out Boolean)
478 procedure Unlock
(L
: not null access Lock
) is
484 (L
: not null access RTS_Lock
;
485 Global_Lock
: Boolean := False)
491 procedure Unlock
(T
: Task_Id
) is
500 procedure Unlock_RTS
is
508 procedure Wakeup
(T
: Task_Id
; Reason
: System
.Tasking
.Task_States
) is
518 (L
: not null access Lock
;
519 Ceiling_Violation
: out Boolean)
522 Ceiling_Violation
:= False;
526 (L
: not null access RTS_Lock
;
527 Global_Lock
: Boolean := False)
533 procedure Write_Lock
(T
: Task_Id
) is
542 procedure Yield
(Do_Yield
: Boolean := True) is
547 end System
.Task_Primitives
.Operations
;