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 --
9 -- Copyright (C) 1992-2002, 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 2, or (at your option) any later ver- --
14 -- sion. GNARL 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNARL; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNARL was developed by the GNARL team at Florida State University. It is --
30 -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). --
32 ------------------------------------------------------------------------------
34 -- This is a no tasking version of this package
36 -- This package contains all the GNULL primitives that interface directly
37 -- with the underlying OS.
40 -- Turn off polling, we do not want ATC polling to take place during
41 -- tasking operations. It causes infinite loops and other problems.
44 -- used for Ada_Task_Control_Block
47 with System
.Error_Reporting
;
50 package body System
.Task_Primitives
.Operations
is
53 use System
.Parameters
;
55 pragma Warnings
(Off
);
56 -- Turn off warnings since so many unreferenced parameters
62 procedure Stack_Guard
(T
: ST
.Task_ID
; On
: Boolean) is
71 function Get_Thread_Id
(T
: ST
.Task_ID
) return OSI
.Thread_Id
is
73 return OSI
.Thread_Id
(T
.Common
.LL
.Thread
);
80 function Self
return Task_ID
is
89 procedure Initialize_Lock
90 (Prio
: System
.Any_Priority
;
97 procedure Initialize_Lock
(L
: access RTS_Lock
; Level
: Lock_Level
) is
106 procedure Finalize_Lock
(L
: access Lock
) is
111 procedure Finalize_Lock
(L
: access RTS_Lock
) is
120 procedure Write_Lock
(L
: access Lock
; Ceiling_Violation
: out Boolean) is
122 Ceiling_Violation
:= False;
126 (L
: access RTS_Lock
;
127 Global_Lock
: Boolean := False)
133 procedure Write_Lock
(T
: Task_ID
) is
142 procedure Read_Lock
(L
: access Lock
; Ceiling_Violation
: out Boolean) is
144 Ceiling_Violation
:= False;
151 procedure Unlock
(L
: access Lock
) is
156 procedure Unlock
(L
: access RTS_Lock
; Global_Lock
: Boolean := False) is
161 procedure Unlock
(T
: Task_ID
) is
170 procedure Sleep
(Self_ID
: Task_ID
; Reason
: System
.Tasking
.Task_States
) is
179 procedure Timed_Sleep
182 Mode
: ST
.Delay_Modes
;
183 Reason
: System
.Tasking
.Task_States
;
184 Timedout
: out Boolean;
185 Yielded
: out Boolean) is
195 procedure Timed_Delay
198 Mode
: ST
.Delay_Modes
) is
203 ---------------------
204 -- Monotonic_Clock --
205 ---------------------
207 function Monotonic_Clock
return Duration is
216 function RT_Resolution
return Duration is
225 procedure Wakeup
(T
: Task_ID
; Reason
: System
.Tasking
.Task_States
) is
234 procedure Set_Priority
236 Prio
: System
.Any_Priority
;
237 Loss_Of_Inheritance
: Boolean := False) is
246 function Get_Priority
(T
: Task_ID
) return System
.Any_Priority
is
255 procedure Enter_Task
(Self_ID
: Task_ID
) is
264 function New_ATCB
(Entry_Num
: Task_Entry_Index
) return Task_ID
is
266 return new Ada_Task_Control_Block
(Entry_Num
);
269 ----------------------
271 ----------------------
273 procedure Initialize_TCB
(Self_ID
: Task_ID
; Succeeded
: out Boolean) is
282 procedure Create_Task
284 Wrapper
: System
.Address
;
285 Stack_Size
: System
.Parameters
.Size_Type
;
286 Priority
: System
.Any_Priority
;
287 Succeeded
: out Boolean) is
296 procedure Finalize_TCB
(T
: Task_ID
) is
305 procedure Exit_Task
is
314 procedure Abort_Task
(T
: Task_ID
) is
323 procedure Yield
(Do_Yield
: Boolean := True) is
332 -- Dummy versions. The only currently working versions is for solaris
335 function Check_Exit
(Self_ID
: ST
.Task_ID
) return Boolean is
344 function Check_No_Locks
(Self_ID
: ST
.Task_ID
) return Boolean is
349 ----------------------
350 -- Environment_Task --
351 ----------------------
353 function Environment_Task
return Task_ID
is
356 end Environment_Task
;
362 procedure Lock_RTS
is
371 procedure Unlock_RTS
is
380 function Suspend_Task
382 Thread_Self
: OSI
.Thread_Id
)
395 Thread_Self
: OSI
.Thread_Id
)
406 procedure Initialize
(Environment_Task
: Task_ID
) is
411 No_Tasking
: Boolean;
414 -- Can't raise an exception because target independent packages try to
415 -- do an Abort_Defer, which gets a memory fault.
418 System
.Error_Reporting
.Shutdown
419 ("Tasking not implemented on this configuration");
420 end System
.Task_Primitives
.Operations
;