]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/ada/5qtaspri.ads
Fix for bug #2944, reported by David Holmes <dholmes@dltech.com.au>
[thirdparty/gcc.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 -- Copyright (C) 1991-2001, Florida State University --
10 -- --
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. --
21 -- --
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. --
28 -- --
29 -- GNARL was developed by the GNARL team at Florida State University. It is --
30 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
31 -- State University (http://www.gnat.com). --
32 -- --
33 ------------------------------------------------------------------------------
34
35 -- RT_GNU/Linux version
36
37 pragma Polling (Off);
38 -- Turn off polling, we do not want ATC polling to take place during
39 -- tasking operations. It causes infinite loops and other problems.
40
41 with System.OS_Interface;
42
43 package System.Task_Primitives is
44
45 type Lock is limited private;
46 -- Used for implementation of protected objects.
47
48 type Lock_Ptr is limited private;
49
50 type RTS_Lock is limited private;
51 -- Used inside the runtime system. The difference between Lock and the
52 -- RTS_Lock is that the later one serves only as a semaphore so that do
53 -- not check for ceiling violations.
54 type RTS_Lock_Ptr is limited private;
55
56 type Task_Body_Access is access procedure;
57 -- Pointer to the task body's entry point (or possibly a wrapper
58 -- declared local to the GNARL).
59
60 type Private_Data is limited private;
61 -- Any information that the GNULLI needs maintained on a per-task
62 -- basis. A component of this type is guaranteed to be included
63 -- in the Ada_Task_Control_Block.
64
65 private
66
67 type RT_GNU_Linux_Lock is record
68 Ceiling_Priority : System.Any_Priority;
69 Pre_Locking_Priority : System.Any_Priority;
70 -- Used to store the task's active priority before it
71 -- acquires the lock
72
73 Owner : System.Address;
74 -- This is really a Task_ID, but we can't use that type
75 -- here because this System.Tasking is "with"
76 -- the current package -- a circularity.
77 end record;
78
79 type Lock is new RT_GNU_Linux_Lock;
80 type RTS_Lock is new RT_GNU_Linux_Lock;
81
82 type RTS_Lock_Ptr is access all RTS_Lock;
83 type Lock_Ptr is access all Lock;
84
85 type Private_Data is record
86 Stack : System.Address;
87 -- A stack space needed for the task. the space is allocated
88 -- when the task is being created and is deallocated when
89 -- the TCB for the task is finalized
90
91 Uses_Fp : Integer;
92 -- A flag to indicate whether the task is going to use floating-
93 -- point unit. It's set to 1, indicating FP unit is always going
94 -- to be used. The reason is that it is in this private record and
95 -- necessary operation has to be provided for a user to call so as
96 -- to change its value
97
98 Magic : Integer;
99 -- A special value is going to be stored in it when a task is
100 -- created. The value is RT_TASK_MAGIC (16#754d2774#) as declared
101 -- in System.OS_Interface
102
103 State : System.OS_Interface.Rt_Task_States;
104 -- Shows whether the task is RT_TASK_READY, RT_TASK_DELAYED or
105 -- RT_TASK_DORMANT to support suspend, wait, wakeup.
106
107 Stack_Bottom : System.Address;
108
109 Active_Priority : System.Any_Priority;
110 -- Active priority of the task
111
112 Period : System.OS_Interface.RTIME;
113 -- Intended originally to store the period of the task, but not used
114 -- in the current implementation
115
116 Resume_Time : System.OS_Interface.RTIME;
117 -- Store the time the task has to be awakened
118
119 Next : System.Address;
120 -- This really is a Task_ID, used to link the Available_TCBs.
121
122 Succ : System.Address;
123 pragma Volatile (Succ);
124 Pred : System.Address;
125 pragma Volatile (Pred);
126 -- These really are Task_ID, used to implement a circular doubly
127 -- linked list for task queue
128
129 L : aliased RTS_Lock;
130
131 Outer_Lock : RTS_Lock_Ptr := null;
132 -- Used to track which Lock the task is holding is the outermost
133 -- one in order to implement priority setting and inheritance
134 end record;
135
136 -- ???? May need to use pragma Atomic or Volatile on some
137 -- components; may also need to specify aliased for some.
138 end System.Task_Primitives;