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 --
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 -- RT_GNU/Linux version
40 -- Turn off polling, we do not want ATC polling to take place during
41 -- tasking operations. It causes infinite loops and other problems.
43 with System
.OS_Interface
;
45 package System
.Task_Primitives
is
47 type Lock
is limited private;
48 -- Used for implementation of protected objects.
50 type Lock_Ptr
is limited private;
52 type RTS_Lock
is limited private;
53 -- Used inside the runtime system. The difference between Lock and the
54 -- RTS_Lock is that the later one serves only as a semaphore so that do
55 -- not check for ceiling violations.
56 type RTS_Lock_Ptr
is limited private;
58 type Task_Body_Access
is access procedure;
59 -- Pointer to the task body's entry point (or possibly a wrapper
60 -- declared local to the GNARL).
62 type Private_Data
is limited private;
63 -- Any information that the GNULLI needs maintained on a per-task
64 -- basis. A component of this type is guaranteed to be included
65 -- in the Ada_Task_Control_Block.
69 type RT_GNU_Linux_Lock
is record
70 Ceiling_Priority
: System
.Any_Priority
;
71 Pre_Locking_Priority
: System
.Any_Priority
;
72 -- Used to store the task's active priority before it
75 Owner
: System
.Address
;
76 -- This is really a Task_ID, but we can't use that type
77 -- here because this System.Tasking is "with"
78 -- the current package -- a circularity.
81 type Lock
is new RT_GNU_Linux_Lock
;
82 type RTS_Lock
is new RT_GNU_Linux_Lock
;
84 type RTS_Lock_Ptr
is access all RTS_Lock
;
85 type Lock_Ptr
is access all Lock
;
87 type Private_Data
is record
88 Stack
: System
.Address
;
89 -- A stack space needed for the task. the space is allocated
90 -- when the task is being created and is deallocated when
91 -- the TCB for the task is finalized
94 -- A flag to indicate whether the task is going to use floating-
95 -- point unit. It's set to 1, indicating FP unit is always going
96 -- to be used. The reason is that it is in this private record and
97 -- necessary operation has to be provided for a user to call so as
98 -- to change its value
101 -- A special value is going to be stored in it when a task is
102 -- created. The value is RT_TASK_MAGIC (16#754d2774#) as declared
103 -- in System.OS_Interface
105 State
: System
.OS_Interface
.Rt_Task_States
;
106 -- Shows whether the task is RT_TASK_READY, RT_TASK_DELAYED or
107 -- RT_TASK_DORMANT to support suspend, wait, wakeup.
109 Stack_Bottom
: System
.Address
;
111 Active_Priority
: System
.Any_Priority
;
112 -- Active priority of the task
114 Period
: System
.OS_Interface
.RTIME
;
115 -- Intended originally to store the period of the task, but not used
116 -- in the current implementation
118 Resume_Time
: System
.OS_Interface
.RTIME
;
119 -- Store the time the task has to be awakened
121 Next
: System
.Address
;
122 -- This really is a Task_ID, used to link the Available_TCBs.
124 Succ
: System
.Address
;
125 pragma Volatile
(Succ
);
126 Pred
: System
.Address
;
127 pragma Volatile
(Pred
);
128 -- These really are Task_ID, used to implement a circular doubly
129 -- linked list for task queue
131 L
: aliased RTS_Lock
;
133 Outer_Lock
: RTS_Lock_Ptr
:= null;
134 -- Used to track which Lock the task is holding is the outermost
135 -- one in order to implement priority setting and inheritance
138 -- ???? May need to use pragma Atomic or Volatile on some
139 -- components; may also need to specify aliased for some.
140 end System
.Task_Primitives
;