OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / ada / 5qtaspri.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                 GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS              --
4 --                                                                          --
5 --                 S Y S T E M . T A S K _ P R I M I T I V E S              --
6 --                                                                          --
7 --                                  S p e c                                 --
8 --                                                                          --
9 --                                                                          --
10 --            Copyright (C) 1991-2001, Florida State University             --
11 --                                                                          --
12 -- GNARL is free software; you can  redistribute it  and/or modify it under --
13 -- terms of the  GNU General Public License as published  by the Free Soft- --
14 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
15 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
18 -- for  more details.  You should have  received  a copy of the GNU General --
19 -- Public License  distributed with GNARL; see file COPYING.  If not, write --
20 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
21 -- MA 02111-1307, USA.                                                      --
22 --                                                                          --
23 -- As a special exception,  if other files  instantiate  generics from this --
24 -- unit, or you link  this unit with other files  to produce an executable, --
25 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
26 -- covered  by the  GNU  General  Public  License.  This exception does not --
27 -- however invalidate  any other reasons why  the executable file  might be --
28 -- covered by the  GNU Public License.                                      --
29 --                                                                          --
30 -- GNARL was developed by the GNARL team at Florida State University. It is --
31 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
32 -- State University (http://www.gnat.com).                                  --
33 --                                                                          --
34 ------------------------------------------------------------------------------
35
36 --  RT_GNU/Linux version
37
38 pragma Polling (Off);
39 --  Turn off polling, we do not want ATC polling to take place during
40 --  tasking operations. It causes infinite loops and other problems.
41
42 with System.OS_Interface;
43
44 package System.Task_Primitives is
45
46    type Lock is limited private;
47    --  Used for implementation of protected objects.
48
49    type Lock_Ptr is limited private;
50
51    type RTS_Lock is limited private;
52    --  Used inside the runtime system. The difference between Lock and the
53    --  RTS_Lock is that the later one serves only as a semaphore so that do
54    --  not check for ceiling violations.
55    type RTS_Lock_Ptr is limited private;
56
57    type Task_Body_Access is access procedure;
58    --  Pointer to the task body's entry point (or possibly a wrapper
59    --  declared local to the GNARL).
60
61    type Private_Data is limited private;
62    --  Any information that the GNULLI needs maintained on a per-task
63    --  basis.  A component of this type is guaranteed to be included
64    --  in the Ada_Task_Control_Block.
65
66 private
67
68    type RT_GNU_Linux_Lock is record
69       Ceiling_Priority     : System.Any_Priority;
70       Pre_Locking_Priority : System.Any_Priority;
71       --  Used to store the task's active priority before it
72       --  acquires the lock
73
74       Owner : System.Address;
75       --  This is really a Task_ID, but we can't use that type
76       --  here because this System.Tasking is "with"
77       --  the current package -- a circularity.
78    end record;
79
80    type Lock is new RT_GNU_Linux_Lock;
81    type RTS_Lock is new RT_GNU_Linux_Lock;
82
83    type RTS_Lock_Ptr is access all RTS_Lock;
84    type Lock_Ptr is access all Lock;
85
86    type Private_Data is record
87       Stack : System.Address;
88       --  A stack space needed for the task. the space is allocated
89       --  when the task is being created and is deallocated when
90       --  the TCB for the task is finalized
91
92       Uses_Fp : Integer;
93       --  A flag to indicate whether the task is going to use floating-
94       --  point unit. It's set to 1, indicating FP unit is always going
95       --  to be used. The reason is that it is in this private record and
96       --  necessary operation has to be provided for a user to call so as
97       --  to change its value
98
99       Magic : Integer;
100       --  A special value is going to be stored in it when a task is
101       --  created. The value is RT_TASK_MAGIC (16#754d2774#) as declared
102       --  in System.OS_Interface
103
104       State : System.OS_Interface.Rt_Task_States;
105       --  Shows whether the task is RT_TASK_READY, RT_TASK_DELAYED or
106       --  RT_TASK_DORMANT to support suspend, wait, wakeup.
107
108       Stack_Bottom : System.Address;
109
110       Active_Priority  : System.Any_Priority;
111       --  Active priority of the task
112
113       Period : System.OS_Interface.RTIME;
114       --  Intended originally to store the period of the task, but not used
115       --  in the current implementation
116
117       Resume_Time : System.OS_Interface.RTIME;
118       --  Store the time the task has to be awakened
119
120       Next : System.Address;
121       --  This really is a Task_ID, used to link the Available_TCBs.
122
123       Succ : System.Address;
124       pragma Volatile (Succ);
125       Pred : System.Address;
126       pragma Volatile (Pred);
127       --  These really are Task_ID, used to implement a circular doubly
128       --  linked list for task queue
129
130       L : aliased RTS_Lock;
131
132       Outer_Lock : RTS_Lock_Ptr := null;
133       --  Used to track which Lock the task is holding is the outermost
134       --  one in order to implement priority setting and inheritance
135    end record;
136
137    --  ????  May need to use pragma Atomic or Volatile on some
138    --  components; may also need to specify aliased for some.
139 end System.Task_Primitives;