1 ------------------------------------------------------------------------------
3 -- GNU ADA 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 --
11 -- Copyright (C) 1991-2001, Florida State University --
13 -- GNARL is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNARL; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
31 -- GNARL was developed by the GNARL team at Florida State University. It is --
32 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
33 -- State University (http://www.gnat.com). --
35 ------------------------------------------------------------------------------
37 -- This is a no tasking version of this package
39 -- This package contains all the GNULL primitives that interface directly
40 -- with the underlying OS.
43 -- Turn off polling, we do not want ATC polling to take place during
44 -- tasking operations. It causes infinite loops and other problems.
47 -- used for Ada_Task_Control_Block
50 with System
.OS_Primitives
;
51 -- used for Delay_Modes
53 with System
.Error_Reporting
;
56 package body System
.Task_Primitives
.Operations
is
59 use System
.Parameters
;
60 use System
.OS_Primitives
;
66 procedure Stack_Guard
(T
: ST
.Task_ID
; On
: Boolean) is
75 function Get_Thread_Id
(T
: ST
.Task_ID
) return OSI
.Thread_Id
is
77 return OSI
.Thread_Id
(T
.Common
.LL
.Thread
);
84 function Self
return Task_ID
is
93 procedure Initialize_Lock
94 (Prio
: System
.Any_Priority
;
101 procedure Initialize_Lock
(L
: access RTS_Lock
; Level
: Lock_Level
) is
110 procedure Finalize_Lock
(L
: access Lock
) is
115 procedure Finalize_Lock
(L
: access RTS_Lock
) is
124 procedure Write_Lock
(L
: access Lock
; Ceiling_Violation
: out Boolean) is
126 Ceiling_Violation
:= False;
129 procedure Write_Lock
(L
: access RTS_Lock
) is
134 procedure Write_Lock
(T
: Task_ID
) is
143 procedure Read_Lock
(L
: access Lock
; Ceiling_Violation
: out Boolean) is
145 Ceiling_Violation
:= False;
152 procedure Unlock
(L
: access Lock
) is
157 procedure Unlock
(L
: access RTS_Lock
) is
162 procedure Unlock
(T
: Task_ID
) is
171 procedure Sleep
(Self_ID
: Task_ID
;
172 Reason
: System
.Tasking
.Task_States
) is
181 procedure Timed_Sleep
184 Mode
: ST
.Delay_Modes
;
185 Reason
: System
.Tasking
.Task_States
;
186 Timedout
: out Boolean;
187 Yielded
: out Boolean) is
197 procedure Timed_Delay
200 Mode
: ST
.Delay_Modes
)
204 procedure sleep
(How_Long
: Natural);
205 pragma Import
(C
, sleep
, "sleep");
208 if Mode
= Relative
then
211 Rel_Time
:= Time
- Monotonic_Clock
;
214 if Rel_Time
> 0.0 then
215 sleep
(Natural (Rel_Time
));
219 ---------------------
220 -- Monotonic_Clock --
221 ---------------------
223 function Monotonic_Clock
return Duration is
232 function RT_Resolution
return Duration is
241 procedure Wakeup
(T
: Task_ID
; Reason
: System
.Tasking
.Task_States
) is
250 procedure Set_Priority
252 Prio
: System
.Any_Priority
;
253 Loss_Of_Inheritance
: Boolean := False) is
262 function Get_Priority
(T
: Task_ID
) return System
.Any_Priority
is
271 procedure Enter_Task
(Self_ID
: Task_ID
) is
280 function New_ATCB
(Entry_Num
: Task_Entry_Index
) return Task_ID
is
282 return new Ada_Task_Control_Block
(Entry_Num
);
285 ----------------------
287 ----------------------
289 procedure Initialize_TCB
(Self_ID
: Task_ID
; Succeeded
: out Boolean) is
298 procedure Create_Task
300 Wrapper
: System
.Address
;
301 Stack_Size
: System
.Parameters
.Size_Type
;
302 Priority
: System
.Any_Priority
;
303 Succeeded
: out Boolean)
313 procedure Finalize_TCB
(T
: Task_ID
) is
322 procedure Exit_Task
is
331 procedure Abort_Task
(T
: Task_ID
) is
340 procedure Yield
(Do_Yield
: Boolean := True) is
349 -- Dummy versions. The only currently working versions is for solaris
352 function Check_Exit
(Self_ID
: ST
.Task_ID
) return Boolean is
361 function Check_No_Locks
(Self_ID
: ST
.Task_ID
) return Boolean is
366 ----------------------
367 -- Environment_Task --
368 ----------------------
370 function Environment_Task
return Task_ID
is
373 end Environment_Task
;
375 -------------------------
376 -- Lock_All_Tasks_List --
377 -------------------------
379 procedure Lock_All_Tasks_List
is
382 end Lock_All_Tasks_List
;
384 ---------------------------
385 -- Unlock_All_Tasks_List --
386 ---------------------------
388 procedure Unlock_All_Tasks_List
is
391 end Unlock_All_Tasks_List
;
397 function Suspend_Task
399 Thread_Self
: OSI
.Thread_Id
) return Boolean is
410 Thread_Self
: OSI
.Thread_Id
) return Boolean is
419 procedure Initialize
(Environment_Task
: Task_ID
) is
424 No_Tasking
: Boolean;
428 -- Can't raise an exception because target independent packages try to
429 -- do an Abort_Defer, which gets a memory fault.
432 System
.Error_Reporting
.Shutdown
433 ("Tasking not implemented on this configuration");
434 end System
.Task_Primitives
.Operations
;