1 | /** |
---|
2 | * @file rtems/score/states.inl |
---|
3 | * |
---|
4 | * This file contains the static inline implementation of the inlined |
---|
5 | * routines associated with thread state information. |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2009. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | * |
---|
16 | * $Id$ |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_SCORE_STATES_H |
---|
20 | # error "Never use <rtems/score/states.inl> directly; include <rtems/score/states.h> instead." |
---|
21 | #endif |
---|
22 | |
---|
23 | #ifndef _RTEMS_SCORE_STATES_INL |
---|
24 | #define _RTEMS_SCORE_STATES_INL |
---|
25 | |
---|
26 | /** |
---|
27 | * @addtogroup ScoreStates |
---|
28 | * @{ |
---|
29 | */ |
---|
30 | |
---|
31 | /** |
---|
32 | * This function sets the given states_to_set into the current_state |
---|
33 | * passed in. The result is returned to the user in current_state. |
---|
34 | * |
---|
35 | * @param[in] states_to_set is the state bits to set |
---|
36 | * @param[in] current_state is the state set to add them to |
---|
37 | * |
---|
38 | * @return This method returns the updated states value. |
---|
39 | */ |
---|
40 | RTEMS_INLINE_ROUTINE States_Control _States_Set ( |
---|
41 | States_Control states_to_set, |
---|
42 | States_Control current_state |
---|
43 | ) |
---|
44 | { |
---|
45 | return (current_state | states_to_set); |
---|
46 | } |
---|
47 | |
---|
48 | /** |
---|
49 | * This function clears the given states_to_clear into the current_state |
---|
50 | * passed in. The result is returned to the user in current_state. |
---|
51 | * |
---|
52 | * @param[in] states_to_set is the state bits to clean |
---|
53 | * @param[in] current_state is the state set to remove them from |
---|
54 | * |
---|
55 | * @return This method returns the updated states value. |
---|
56 | */ |
---|
57 | RTEMS_INLINE_ROUTINE States_Control _States_Clear ( |
---|
58 | States_Control states_to_clear, |
---|
59 | States_Control current_state |
---|
60 | ) |
---|
61 | { |
---|
62 | return (current_state & ~states_to_clear); |
---|
63 | } |
---|
64 | |
---|
65 | /** |
---|
66 | * This function returns true if the_states indicates that the |
---|
67 | * state is READY, and false otherwise. |
---|
68 | * |
---|
69 | * @param[in] the_states is the task state set to test |
---|
70 | * |
---|
71 | * @return This method returns true if the desired state condition is set. |
---|
72 | */ |
---|
73 | RTEMS_INLINE_ROUTINE bool _States_Is_ready ( |
---|
74 | States_Control the_states |
---|
75 | ) |
---|
76 | { |
---|
77 | return (the_states == STATES_READY); |
---|
78 | } |
---|
79 | |
---|
80 | /** |
---|
81 | * This function returns true if the DORMANT state is the ONLY state |
---|
82 | * set in the_states, and false otherwise. |
---|
83 | * |
---|
84 | * @param[in] the_states is the task state set to test |
---|
85 | * |
---|
86 | * @return This method returns true if the desired state condition is set. |
---|
87 | */ |
---|
88 | RTEMS_INLINE_ROUTINE bool _States_Is_only_dormant ( |
---|
89 | States_Control the_states |
---|
90 | ) |
---|
91 | { |
---|
92 | return (the_states == STATES_DORMANT); |
---|
93 | } |
---|
94 | |
---|
95 | /** |
---|
96 | * This function returns true if the DORMANT state is set in |
---|
97 | * the_states, and false otherwise. |
---|
98 | * |
---|
99 | * @param[in] the_states is the task state set to test |
---|
100 | * |
---|
101 | * @return This method returns true if the desired state condition is set. |
---|
102 | */ |
---|
103 | RTEMS_INLINE_ROUTINE bool _States_Is_dormant ( |
---|
104 | States_Control the_states |
---|
105 | ) |
---|
106 | { |
---|
107 | return (the_states & STATES_DORMANT); |
---|
108 | } |
---|
109 | |
---|
110 | /** |
---|
111 | * This function returns true if the SUSPENDED state is set in |
---|
112 | * the_states, and false otherwise. |
---|
113 | * |
---|
114 | * @param[in] the_states is the task state set to test |
---|
115 | * |
---|
116 | * @return This method returns true if the desired state condition is set. |
---|
117 | */ |
---|
118 | RTEMS_INLINE_ROUTINE bool _States_Is_suspended ( |
---|
119 | States_Control the_states |
---|
120 | ) |
---|
121 | { |
---|
122 | return (the_states & STATES_SUSPENDED); |
---|
123 | } |
---|
124 | |
---|
125 | /** |
---|
126 | * This function returns true if the TRANSIENT state is set in |
---|
127 | * the_states, and false otherwise. |
---|
128 | * |
---|
129 | * @param[in] the_states is the task state set to test |
---|
130 | * |
---|
131 | * @return This method returns true if the desired state condition is set. |
---|
132 | */ |
---|
133 | RTEMS_INLINE_ROUTINE bool _States_Is_transient ( |
---|
134 | States_Control the_states |
---|
135 | ) |
---|
136 | { |
---|
137 | return (the_states & STATES_TRANSIENT); |
---|
138 | } |
---|
139 | |
---|
140 | /** |
---|
141 | * This function returns true if the DELAYING state is set in |
---|
142 | * the_states, and false otherwise. |
---|
143 | * |
---|
144 | * @param[in] the_states is the task state set to test |
---|
145 | * |
---|
146 | * @return This method returns true if the desired state condition is set. |
---|
147 | */ |
---|
148 | RTEMS_INLINE_ROUTINE bool _States_Is_delaying ( |
---|
149 | States_Control the_states |
---|
150 | ) |
---|
151 | { |
---|
152 | return (the_states & STATES_DELAYING); |
---|
153 | } |
---|
154 | |
---|
155 | /** |
---|
156 | * This function returns true if the WAITING_FOR_BUFFER state is set in |
---|
157 | * the_states, and false otherwise. |
---|
158 | * |
---|
159 | * @param[in] the_states is the task state set to test |
---|
160 | * |
---|
161 | * @return This method returns true if the desired state condition is set. |
---|
162 | */ |
---|
163 | RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_buffer ( |
---|
164 | States_Control the_states |
---|
165 | ) |
---|
166 | { |
---|
167 | return (the_states & STATES_WAITING_FOR_BUFFER); |
---|
168 | } |
---|
169 | |
---|
170 | /** |
---|
171 | * This function returns true if the WAITING_FOR_SEGMENT state is set in |
---|
172 | * the_states, and false otherwise. |
---|
173 | * |
---|
174 | * @param[in] the_states is the task state set to test |
---|
175 | * |
---|
176 | * @return This method returns true if the desired state condition is set. |
---|
177 | */ |
---|
178 | RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_segment ( |
---|
179 | States_Control the_states |
---|
180 | ) |
---|
181 | { |
---|
182 | return (the_states & STATES_WAITING_FOR_SEGMENT); |
---|
183 | } |
---|
184 | |
---|
185 | /** |
---|
186 | * This function returns true if the WAITING_FOR_MESSAGE state is set in |
---|
187 | * the_states, and false otherwise. |
---|
188 | * |
---|
189 | * @param[in] the_states is the task state set to test |
---|
190 | * |
---|
191 | * @return This method returns true if the desired state condition is set. |
---|
192 | */ |
---|
193 | RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_message ( |
---|
194 | States_Control the_states |
---|
195 | ) |
---|
196 | { |
---|
197 | return (the_states & STATES_WAITING_FOR_MESSAGE); |
---|
198 | } |
---|
199 | |
---|
200 | /** |
---|
201 | * This function returns true if the WAITING_FOR_EVENT state is set in |
---|
202 | * the_states, and false otherwise. |
---|
203 | * |
---|
204 | * @param[in] the_states is the task state set to test |
---|
205 | * |
---|
206 | * @return This method returns true if the desired state condition is set. |
---|
207 | */ |
---|
208 | RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_event ( |
---|
209 | States_Control the_states |
---|
210 | ) |
---|
211 | { |
---|
212 | return (the_states & STATES_WAITING_FOR_EVENT); |
---|
213 | } |
---|
214 | |
---|
215 | /** |
---|
216 | * This function returns true if the WAITING_FOR_MUTEX state |
---|
217 | * is set in the_states, and false otherwise. |
---|
218 | * |
---|
219 | * @param[in] the_states is the task state set to test |
---|
220 | * |
---|
221 | * @return This method returns true if the desired state condition is set. |
---|
222 | */ |
---|
223 | RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_mutex ( |
---|
224 | States_Control the_states |
---|
225 | ) |
---|
226 | { |
---|
227 | return (the_states & STATES_WAITING_FOR_MUTEX); |
---|
228 | } |
---|
229 | |
---|
230 | /** |
---|
231 | * This function returns true if the WAITING_FOR_SEMAPHORE state |
---|
232 | * is set in the_states, and false otherwise. |
---|
233 | * |
---|
234 | * @param[in] the_states is the task state set to test |
---|
235 | * |
---|
236 | * @return This method returns true if the desired state condition is set. |
---|
237 | */ |
---|
238 | RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_semaphore ( |
---|
239 | States_Control the_states |
---|
240 | ) |
---|
241 | { |
---|
242 | return (the_states & STATES_WAITING_FOR_SEMAPHORE); |
---|
243 | } |
---|
244 | |
---|
245 | /** |
---|
246 | * This function returns true if the WAITING_FOR_TIME state is set in |
---|
247 | * the_states, and false otherwise. |
---|
248 | * |
---|
249 | * @param[in] the_states is the task state set to test |
---|
250 | * |
---|
251 | * @return This method returns true if the desired state condition is set. |
---|
252 | */ |
---|
253 | RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_time ( |
---|
254 | States_Control the_states |
---|
255 | ) |
---|
256 | { |
---|
257 | return (the_states & STATES_WAITING_FOR_TIME); |
---|
258 | } |
---|
259 | |
---|
260 | /** |
---|
261 | * This function returns true if the WAITING_FOR_TIME state is set in |
---|
262 | * the_states, and false otherwise. |
---|
263 | * |
---|
264 | * @param[in] the_states is the task state set to test |
---|
265 | * |
---|
266 | * @return This method returns true if the desired state condition is set. |
---|
267 | */ |
---|
268 | RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_rpc_reply ( |
---|
269 | States_Control the_states |
---|
270 | ) |
---|
271 | { |
---|
272 | return (the_states & STATES_WAITING_FOR_RPC_REPLY); |
---|
273 | } |
---|
274 | |
---|
275 | /** |
---|
276 | * This function returns true if the WAITING_FOR_PERIOD state is set in |
---|
277 | * the_states, and false otherwise. |
---|
278 | * |
---|
279 | * @param[in] the_states is the task state set to test |
---|
280 | * |
---|
281 | * @return This method returns true if the desired state condition is set. |
---|
282 | */ |
---|
283 | RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_period ( |
---|
284 | States_Control the_states |
---|
285 | ) |
---|
286 | { |
---|
287 | return (the_states & STATES_WAITING_FOR_PERIOD); |
---|
288 | } |
---|
289 | |
---|
290 | /** |
---|
291 | * This function returns true if the task's state is set in |
---|
292 | * way that allows it to be interrupted by a signal. |
---|
293 | * |
---|
294 | * @param[in] the_states is the task state set to test |
---|
295 | * |
---|
296 | * @return This method returns true if the desired state condition is set. |
---|
297 | */ |
---|
298 | RTEMS_INLINE_ROUTINE bool _States_Is_interruptible_by_signal ( |
---|
299 | States_Control the_states |
---|
300 | ) |
---|
301 | { |
---|
302 | return (the_states & STATES_INTERRUPTIBLE_BY_SIGNAL); |
---|
303 | |
---|
304 | } |
---|
305 | /** |
---|
306 | * This function returns true if one of the states which indicates |
---|
307 | * that a task is blocked waiting for a local resource is set in |
---|
308 | * the_states, and false otherwise. |
---|
309 | * |
---|
310 | * @param[in] the_states is the task state set to test |
---|
311 | * |
---|
312 | * @return This method returns true if the desired state condition is set. |
---|
313 | */ |
---|
314 | |
---|
315 | RTEMS_INLINE_ROUTINE bool _States_Is_locally_blocked ( |
---|
316 | States_Control the_states |
---|
317 | ) |
---|
318 | { |
---|
319 | return (the_states & STATES_LOCALLY_BLOCKED); |
---|
320 | } |
---|
321 | |
---|
322 | /** |
---|
323 | * This function returns true if one of the states which indicates |
---|
324 | * that a task is blocked waiting for a local resource is set in |
---|
325 | * the_states, and false otherwise. |
---|
326 | * |
---|
327 | * @param[in] the_states is the task state set to test |
---|
328 | * |
---|
329 | * @return This method returns true if the state indicates that the |
---|
330 | * assocated thread is waiting on a thread queue. |
---|
331 | */ |
---|
332 | RTEMS_INLINE_ROUTINE bool _States_Is_waiting_on_thread_queue ( |
---|
333 | States_Control the_states |
---|
334 | ) |
---|
335 | { |
---|
336 | return (the_states & STATES_WAITING_ON_THREAD_QUEUE); |
---|
337 | } |
---|
338 | |
---|
339 | /** |
---|
340 | * This function returns true if one of the states which indicates |
---|
341 | * that a task is blocked is set in the_states, and false otherwise. |
---|
342 | * |
---|
343 | * @param[in] the_states is the task state set to test |
---|
344 | * |
---|
345 | * @return This method returns true if the state indicates that the |
---|
346 | * assocated thread is blocked. |
---|
347 | */ |
---|
348 | RTEMS_INLINE_ROUTINE bool _States_Is_blocked ( |
---|
349 | States_Control the_states |
---|
350 | ) |
---|
351 | { |
---|
352 | return (the_states & STATES_BLOCKED); |
---|
353 | } |
---|
354 | |
---|
355 | /** |
---|
356 | * This function returns true if any of the states in the mask |
---|
357 | * are set in the_states, and false otherwise. |
---|
358 | * |
---|
359 | * @param[in] the_states is the task state set to test |
---|
360 | * @param[in] mask is the state bits to test for |
---|
361 | * |
---|
362 | * @return This method returns true if the indicates state condition is set. |
---|
363 | */ |
---|
364 | RTEMS_INLINE_ROUTINE bool _States_Are_set ( |
---|
365 | States_Control the_states, |
---|
366 | States_Control mask |
---|
367 | ) |
---|
368 | { |
---|
369 | return ( (the_states & mask) != STATES_READY); |
---|
370 | } |
---|
371 | |
---|
372 | /**@}*/ |
---|
373 | |
---|
374 | #endif |
---|
375 | /* end of include file */ |
---|