1 | /* thread.inl |
---|
2 | * |
---|
3 | * This file contains the macro implementation of the inlined |
---|
4 | * routines from the Thread handler. |
---|
5 | * |
---|
6 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * All rights assigned to U.S. Government, 1994. |
---|
9 | * |
---|
10 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
11 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
12 | * notice must appear in all copies of this file and its derivatives. |
---|
13 | * |
---|
14 | * $Id$ |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef __THREAD_inl |
---|
18 | #define __THREAD_inl |
---|
19 | |
---|
20 | /*PAGE |
---|
21 | * |
---|
22 | * _Thread_Stop_multitasking |
---|
23 | * |
---|
24 | */ |
---|
25 | |
---|
26 | STATIC INLINE void _Thread_Stop_multitasking( void ) |
---|
27 | { |
---|
28 | _Context_Switch( &_Thread_Executing->Registers, &_Thread_BSP_context ); |
---|
29 | } |
---|
30 | |
---|
31 | /*PAGE |
---|
32 | * |
---|
33 | * _Thread_Is_executing |
---|
34 | * |
---|
35 | */ |
---|
36 | |
---|
37 | STATIC INLINE boolean _Thread_Is_executing ( |
---|
38 | Thread_Control *the_thread |
---|
39 | ) |
---|
40 | { |
---|
41 | return ( the_thread == _Thread_Executing ); |
---|
42 | } |
---|
43 | |
---|
44 | /*PAGE |
---|
45 | * |
---|
46 | * _Thread_Is_heir |
---|
47 | * |
---|
48 | */ |
---|
49 | |
---|
50 | STATIC INLINE boolean _Thread_Is_heir ( |
---|
51 | Thread_Control *the_thread |
---|
52 | ) |
---|
53 | { |
---|
54 | return ( the_thread == _Thread_Heir ); |
---|
55 | } |
---|
56 | |
---|
57 | /*PAGE |
---|
58 | * |
---|
59 | * _Thread_Is_executing_also_the_heir |
---|
60 | * |
---|
61 | */ |
---|
62 | |
---|
63 | STATIC INLINE boolean _Thread_Is_executing_also_the_heir( void ) |
---|
64 | { |
---|
65 | return ( _Thread_Executing == _Thread_Heir ); |
---|
66 | } |
---|
67 | |
---|
68 | /*PAGE |
---|
69 | * |
---|
70 | * _Thread_Resume |
---|
71 | * |
---|
72 | */ |
---|
73 | |
---|
74 | STATIC INLINE void _Thread_Resume ( |
---|
75 | Thread_Control *the_thread |
---|
76 | ) |
---|
77 | { |
---|
78 | _Thread_Clear_state( the_thread, STATES_SUSPENDED ); |
---|
79 | } |
---|
80 | |
---|
81 | /*PAGE |
---|
82 | * |
---|
83 | * _Thread_Unblock |
---|
84 | * |
---|
85 | */ |
---|
86 | |
---|
87 | STATIC INLINE void _Thread_Unblock ( |
---|
88 | Thread_Control *the_thread |
---|
89 | ) |
---|
90 | { |
---|
91 | _Thread_Clear_state( the_thread, STATES_BLOCKED ); |
---|
92 | } |
---|
93 | |
---|
94 | /*PAGE |
---|
95 | * |
---|
96 | * _Thread_Restart_self |
---|
97 | * |
---|
98 | */ |
---|
99 | |
---|
100 | STATIC INLINE void _Thread_Restart_self( void ) |
---|
101 | { |
---|
102 | if ( _Thread_Executing->fp_context != NULL ) |
---|
103 | _Context_Restore_fp( &_Thread_Executing->fp_context ); |
---|
104 | |
---|
105 | _CPU_Context_Restart_self( &_Thread_Executing->Registers ); |
---|
106 | } |
---|
107 | |
---|
108 | /*PAGE |
---|
109 | * |
---|
110 | * _Thread_Calculate_heir |
---|
111 | * |
---|
112 | */ |
---|
113 | |
---|
114 | STATIC INLINE void _Thread_Calculate_heir( void ) |
---|
115 | { |
---|
116 | _Thread_Heir = (Thread_Control *) |
---|
117 | _Thread_Ready_chain[ _Priority_Get_highest() ].first; |
---|
118 | } |
---|
119 | |
---|
120 | /*PAGE |
---|
121 | * |
---|
122 | * _Thread_Is_allocated_fp |
---|
123 | * |
---|
124 | */ |
---|
125 | |
---|
126 | STATIC INLINE boolean _Thread_Is_allocated_fp ( |
---|
127 | Thread_Control *the_thread |
---|
128 | ) |
---|
129 | { |
---|
130 | return ( the_thread == _Thread_Allocated_fp ); |
---|
131 | } |
---|
132 | |
---|
133 | /*PAGE |
---|
134 | * |
---|
135 | * _Thread_Deallocate_fp |
---|
136 | * |
---|
137 | */ |
---|
138 | |
---|
139 | STATIC INLINE void _Thread_Deallocate_fp( void ) |
---|
140 | { |
---|
141 | _Thread_Allocated_fp = NULL; |
---|
142 | } |
---|
143 | |
---|
144 | /*PAGE |
---|
145 | * |
---|
146 | * _Thread_Disable_dispatch |
---|
147 | * |
---|
148 | */ |
---|
149 | |
---|
150 | STATIC INLINE void _Thread_Disable_dispatch( void ) |
---|
151 | { |
---|
152 | _Thread_Dispatch_disable_level += 1; |
---|
153 | } |
---|
154 | |
---|
155 | /*PAGE |
---|
156 | * |
---|
157 | * _Thread_Enable_dispatch |
---|
158 | * |
---|
159 | */ |
---|
160 | |
---|
161 | #if ( CPU_INLINE_ENABLE_DISPATCH == TRUE ) |
---|
162 | STATIC INLINE void _Thread_Enable_dispatch() |
---|
163 | { |
---|
164 | if ( (--_Thread_Dispatch_disable_level) == 0 ) |
---|
165 | _Thread_Dispatch(); |
---|
166 | } |
---|
167 | #endif |
---|
168 | |
---|
169 | #if ( CPU_INLINE_ENABLE_DISPATCH == FALSE ) |
---|
170 | void _Thread_Enable_dispatch( void ); |
---|
171 | #endif |
---|
172 | |
---|
173 | /*PAGE |
---|
174 | * |
---|
175 | * _Thread_Unnest_dispatch |
---|
176 | * |
---|
177 | */ |
---|
178 | |
---|
179 | STATIC INLINE void _Thread_Unnest_dispatch( void ) |
---|
180 | { |
---|
181 | _Thread_Dispatch_disable_level -= 1; |
---|
182 | } |
---|
183 | |
---|
184 | /*PAGE |
---|
185 | * |
---|
186 | * _Thread_Is_dispatching_enabled |
---|
187 | * |
---|
188 | */ |
---|
189 | |
---|
190 | STATIC INLINE boolean _Thread_Is_dispatching_enabled( void ) |
---|
191 | { |
---|
192 | return ( _Thread_Dispatch_disable_level == 0 ); |
---|
193 | } |
---|
194 | |
---|
195 | /*PAGE |
---|
196 | * |
---|
197 | * _Thread_Is_context_switch_necessary |
---|
198 | * |
---|
199 | */ |
---|
200 | |
---|
201 | STATIC INLINE boolean _Thread_Is_context_switch_necessary( void ) |
---|
202 | { |
---|
203 | return ( _Context_Switch_necessary ); |
---|
204 | } |
---|
205 | |
---|
206 | /*PAGE |
---|
207 | * |
---|
208 | * _Thread_Dispatch_initialization |
---|
209 | * |
---|
210 | */ |
---|
211 | |
---|
212 | STATIC INLINE void _Thread_Dispatch_initialization( void ) |
---|
213 | { |
---|
214 | _Thread_Dispatch_disable_level = 1; |
---|
215 | } |
---|
216 | |
---|
217 | /*PAGE |
---|
218 | * |
---|
219 | * _Thread_Is_null |
---|
220 | * |
---|
221 | */ |
---|
222 | |
---|
223 | STATIC INLINE boolean _Thread_Is_null ( |
---|
224 | Thread_Control *the_thread |
---|
225 | ) |
---|
226 | { |
---|
227 | return ( the_thread == NULL ); |
---|
228 | } |
---|
229 | |
---|
230 | /*PAGE |
---|
231 | * |
---|
232 | * _Thread_Get |
---|
233 | * |
---|
234 | * NOTE: XXX... This routine may be able to be optimized. |
---|
235 | */ |
---|
236 | |
---|
237 | STATIC INLINE Thread_Control *_Thread_Get ( |
---|
238 | Objects_Id id, |
---|
239 | Objects_Locations *location |
---|
240 | ) |
---|
241 | { |
---|
242 | Objects_Classes the_class; |
---|
243 | Objects_Information *information; |
---|
244 | Thread_Control *tp = (Thread_Control *) 0; |
---|
245 | |
---|
246 | if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ) { |
---|
247 | _Thread_Disable_dispatch(); |
---|
248 | *location = OBJECTS_LOCAL; |
---|
249 | tp = _Thread_Executing; |
---|
250 | goto done; |
---|
251 | } |
---|
252 | |
---|
253 | the_class = _Objects_Get_class( id ); |
---|
254 | |
---|
255 | if ( the_class > OBJECTS_CLASSES_LAST ) { |
---|
256 | *location = OBJECTS_ERROR; |
---|
257 | goto done; |
---|
258 | } |
---|
259 | |
---|
260 | information = _Objects_Information_table[ the_class ]; |
---|
261 | |
---|
262 | if ( !information || !information->is_thread ) { |
---|
263 | *location = OBJECTS_ERROR; |
---|
264 | goto done; |
---|
265 | } |
---|
266 | |
---|
267 | tp = (Thread_Control *) _Objects_Get( information, id, location ); |
---|
268 | |
---|
269 | done: |
---|
270 | return tp; |
---|
271 | } |
---|
272 | |
---|
273 | |
---|
274 | /* |
---|
275 | * _Thread_Is_proxy_blocking |
---|
276 | * |
---|
277 | */ |
---|
278 | |
---|
279 | STATIC INLINE boolean _Thread_Is_proxy_blocking ( |
---|
280 | unsigned32 code |
---|
281 | ) |
---|
282 | { |
---|
283 | return (code == THREAD_STATUS_PROXY_BLOCKING); |
---|
284 | } |
---|
285 | |
---|
286 | #endif |
---|
287 | /* end of include file */ |
---|