source: rtems/cpukit/score/include/rtems/score/statesimpl.h @ f78a5f5

Last change on this file since f78a5f5 was f78a5f5, checked in by Chris Johns <chrisj@…>, on Jul 22, 2016 at 1:19:48 AM

score: Add a STATES_DEBUGGER for use by debugging agents to a thread's state.

  • Property mode set to 100644
File size: 14.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief Inlined Routines Associated with Thread State Information
5 *
6 * This file contains the static inline implementation of the inlined
7 * routines associated with thread state information.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2012.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef _RTEMS_SCORE_STATESIMPL_H
20#define _RTEMS_SCORE_STATESIMPL_H
21
22#include <rtems/score/states.h>
23#include <rtems/score/basedefs.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/**
30 * @addtogroup ScoreStates
31 */
32/**@{**/
33
34/*
35 *  The following constants define the individual states which may be
36 *  be used to compose and manipulate a thread's state.
37 */
38
39/** This macro corresponds to a task being ready. */
40#define STATES_READY                           0x00000
41/** This macro corresponds to a task being created but not yet started. */
42#define STATES_DORMANT                         0x00001
43/** This macro corresponds to a task being suspended. */
44#define STATES_SUSPENDED                       0x00002
45/** This macro corresponds to a task which is waiting for a timeout. */
46#define STATES_DELAYING                        0x00008
47/** This macro corresponds to a task waiting until a specific TOD. */
48#define STATES_WAITING_FOR_TIME                0x00010
49/** This macro corresponds to a task waiting for a variable length buffer. */
50#define STATES_WAITING_FOR_BUFFER              0x00020
51/** This macro corresponds to a task waiting for a fixed size segment. */
52#define STATES_WAITING_FOR_SEGMENT             0x00040
53/** This macro corresponds to a task waiting for a message. */
54#define STATES_WAITING_FOR_MESSAGE             0x00080
55/** This macro corresponds to a task waiting for an event. */
56#define STATES_WAITING_FOR_EVENT               0x00100
57/** This macro corresponds to a task waiting for a semaphore. */
58#define STATES_WAITING_FOR_SEMAPHORE           0x00200
59/** This macro corresponds to a task waiting for a mutex. */
60#define STATES_WAITING_FOR_MUTEX               0x00400
61/** This macro corresponds to a task waiting for a condition variable. */
62#define STATES_WAITING_FOR_CONDITION_VARIABLE  0x00800
63/** This macro corresponds to a task waiting for a join while exiting. */
64#define STATES_WAITING_FOR_JOIN_AT_EXIT        0x01000
65/** This macro corresponds to a task waiting for a reply to an MPCI request. */
66#define STATES_WAITING_FOR_RPC_REPLY           0x02000
67/** This macro corresponds to a task waiting for a period. */
68#define STATES_WAITING_FOR_PERIOD              0x04000
69/** This macro corresponds to a task waiting for a signal. */
70#define STATES_WAITING_FOR_SIGNAL              0x08000
71/** This macro corresponds to a task waiting for a barrier. */
72#define STATES_WAITING_FOR_BARRIER             0x10000
73/** This macro corresponds to a task waiting for a RWLock. */
74#define STATES_WAITING_FOR_RWLOCK              0x20000
75/** This macro corresponds to a task waiting for a system event. */
76#define STATES_WAITING_FOR_SYSTEM_EVENT        0x40000
77/** This macro corresponds to a task waiting for BSD wakeup. */
78#define STATES_WAITING_FOR_BSD_WAKEUP          0x80000
79/** This macro corresponds to a task being held by the debugger. */
80#define STATES_DEBUGGER                        0x100000
81/** This macro corresponds to a task being a zombie. */
82#define STATES_ZOMBIE                          0x200000
83/** This macro corresponds to a task those life is changing. */
84#define STATES_LIFE_IS_CHANGING                0x800000
85/** This macro corresponds to a task waiting for a join. */
86#define STATES_WAITING_FOR_JOIN                0x1000000
87/** This macro corresponds to a task waiting for a <sys/lock.h> mutex. */
88#define STATES_WAITING_FOR_SYS_LOCK_MUTEX      0x2000000
89/** This macro corresponds to a task waiting for a <sys/lock.h> semaphore. */
90#define STATES_WAITING_FOR_SYS_LOCK_SEMAPHORE  0x4000000
91/** This macro corresponds to a task waiting for a <sys/lock.h> futex. */
92#define STATES_WAITING_FOR_SYS_LOCK_FUTEX      0x8000000
93
94/** This macro corresponds to a task which is in an interruptible
95 *  blocking state.
96 */
97#define STATES_INTERRUPTIBLE_BY_SIGNAL         0x10000000
98/** This macro corresponds to a task waiting for a <sys/lock.h> condition. */
99#define STATES_WAITING_FOR_SYS_LOCK_CONDITION  0x20000000
100
101/** This macro corresponds to a task waiting for a local object operation. */
102#define STATES_LOCALLY_BLOCKED ( STATES_WAITING_FOR_BUFFER             | \
103                                 STATES_WAITING_FOR_SEGMENT            | \
104                                 STATES_WAITING_FOR_MESSAGE            | \
105                                 STATES_WAITING_FOR_SEMAPHORE          | \
106                                 STATES_WAITING_FOR_MUTEX              | \
107                                 STATES_WAITING_FOR_CONDITION_VARIABLE | \
108                                 STATES_WAITING_FOR_JOIN               | \
109                                 STATES_WAITING_FOR_SIGNAL             | \
110                                 STATES_WAITING_FOR_BARRIER            | \
111                                 STATES_WAITING_FOR_BSD_WAKEUP         | \
112                                 STATES_WAITING_FOR_SYS_LOCK_MUTEX     | \
113                                 STATES_WAITING_FOR_SYS_LOCK_SEMAPHORE | \
114                                 STATES_WAITING_FOR_SYS_LOCK_FUTEX     | \
115                                 STATES_WAITING_FOR_SYS_LOCK_CONDITION | \
116                                 STATES_WAITING_FOR_RWLOCK             )
117
118/** This macro corresponds to a task waiting which is blocked. */
119#define STATES_BLOCKED         ( STATES_DELAYING                | \
120                                 STATES_LOCALLY_BLOCKED         | \
121                                 STATES_WAITING_FOR_TIME        | \
122                                 STATES_WAITING_FOR_PERIOD      | \
123                                 STATES_WAITING_FOR_EVENT       | \
124                                 STATES_WAITING_FOR_RPC_REPLY   | \
125                                 STATES_WAITING_FOR_SYSTEM_EVENT | \
126                                 STATES_INTERRUPTIBLE_BY_SIGNAL )
127
128/** All state bits set to one (provided for _Thread_Start()) */
129#define STATES_ALL_SET 0xffffffff
130
131/**
132 * This function sets the given states_to_set into the current_state
133 * passed in.  The result is returned to the user in current_state.
134 *
135 * @param[in] states_to_set is the state bits to set
136 * @param[in] current_state is the state set to add them to
137 *
138 * @return This method returns the updated states value.
139 */
140RTEMS_INLINE_ROUTINE States_Control _States_Set (
141  States_Control states_to_set,
142  States_Control current_state
143)
144{
145   return (current_state | states_to_set);
146}
147
148/**
149 * This function clears the given states_to_clear into the current_state
150 * passed in.  The result is returned to the user in current_state.
151 *
152 * @param[in] states_to_clear is the state bits to clean
153 * @param[in] current_state is the state set to remove them from
154 *
155 * @return This method returns the updated states value.
156 */
157RTEMS_INLINE_ROUTINE States_Control _States_Clear (
158  States_Control states_to_clear,
159  States_Control current_state
160)
161{
162   return (current_state & ~states_to_clear);
163}
164
165/**
166 * This function returns true if the_states indicates that the
167 * state is READY, and false otherwise.
168 *
169 * @param[in] the_states is the task state set to test
170 *
171 * @return This method returns true if the desired state condition is set.
172 */
173RTEMS_INLINE_ROUTINE bool _States_Is_ready (
174  States_Control the_states
175)
176{
177   return (the_states == STATES_READY);
178}
179
180/**
181 * This function returns true if the DORMANT state is the ONLY state
182 * set in the_states, and false otherwise.
183 *
184 * @param[in] the_states is the task state set to test
185 *
186 * @return This method returns true if the desired state condition is set.
187 */
188RTEMS_INLINE_ROUTINE bool _States_Is_only_dormant (
189  States_Control the_states
190)
191{
192   return (the_states == STATES_DORMANT);
193}
194
195/**
196 * This function returns true if the DORMANT state is set in
197 * the_states, and false otherwise.
198 *
199 * @param[in] the_states is the task state set to test
200 *
201 * @return This method returns true if the desired state condition is set.
202 */
203RTEMS_INLINE_ROUTINE bool _States_Is_dormant (
204  States_Control the_states
205)
206{
207   return (the_states & STATES_DORMANT);
208}
209
210/**
211 * This function returns true if the SUSPENDED state is set in
212 * the_states, and false otherwise.
213 *
214 * @param[in] the_states is the task state set to test
215 *
216 * @return This method returns true if the desired state condition is set.
217 */
218RTEMS_INLINE_ROUTINE bool _States_Is_suspended (
219  States_Control the_states
220)
221{
222   return (the_states & STATES_SUSPENDED);
223}
224
225/**
226 * This function returns true if the DELAYING state is set in
227 * the_states, and false otherwise.
228 *
229 * @param[in] the_states is the task state set to test
230 *
231 * @return This method returns true if the desired state condition is set.
232 */
233RTEMS_INLINE_ROUTINE bool _States_Is_delaying (
234  States_Control the_states
235)
236{
237   return (the_states & STATES_DELAYING);
238}
239
240/**
241 * This function returns true if the WAITING_FOR_BUFFER state is set in
242 * the_states, and false otherwise.
243 *
244 * @param[in] the_states is the task state set to test
245 *
246 * @return This method returns true if the desired state condition is set.
247 */
248RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_buffer (
249  States_Control the_states
250)
251{
252   return (the_states & STATES_WAITING_FOR_BUFFER);
253}
254
255/**
256 * This function returns true if the WAITING_FOR_SEGMENT state is set in
257 * the_states, and false otherwise.
258 *
259 * @param[in] the_states is the task state set to test
260 *
261 * @return This method returns true if the desired state condition is set.
262 */
263RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_segment (
264  States_Control the_states
265)
266{
267   return (the_states & STATES_WAITING_FOR_SEGMENT);
268}
269
270/**
271 * This function returns true if the WAITING_FOR_MESSAGE state is set in
272 * the_states, and false otherwise.
273 *
274 * @param[in] the_states is the task state set to test
275 *
276 * @return This method returns true if the desired state condition is set.
277 */
278RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_message (
279  States_Control the_states
280)
281{
282   return (the_states & STATES_WAITING_FOR_MESSAGE);
283}
284
285/**
286 * This function returns true if the WAITING_FOR_EVENT state is set in
287 * the_states, and false otherwise.
288 *
289 * @param[in] the_states is the task state set to test
290 *
291 * @return This method returns true if the desired state condition is set.
292 */
293RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_event (
294  States_Control the_states
295)
296{
297   return (the_states & STATES_WAITING_FOR_EVENT);
298}
299
300/**
301 * This function returns true if the WAITING_FOR_SYSTEM_EVENT state is set in
302 * the_states, and false otherwise.
303 *
304 * @param[in] the_states is the task state set to test
305 *
306 * @return This method returns true if the desired state condition is set.
307 */
308RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_system_event (
309  States_Control the_states
310)
311{
312   return (the_states & STATES_WAITING_FOR_SYSTEM_EVENT);
313}
314
315/**
316 * This function returns true if the WAITING_FOR_MUTEX state
317 * is set in the_states, and false otherwise.
318 *
319 * @param[in] the_states is the task state set to test
320 *
321 * @return This method returns true if the desired state condition is set.
322 */
323RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_mutex (
324  States_Control the_states
325)
326{
327   return (the_states & STATES_WAITING_FOR_MUTEX);
328}
329
330/**
331 * This function returns true if the WAITING_FOR_SEMAPHORE state
332 * is set in the_states, and false otherwise.
333 *
334 * @param[in] the_states is the task state set to test
335 *
336 * @return This method returns true if the desired state condition is set.
337 */
338RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_semaphore (
339  States_Control the_states
340)
341{
342   return (the_states & STATES_WAITING_FOR_SEMAPHORE);
343}
344
345/**
346 * This function returns true if the WAITING_FOR_TIME state is set in
347 * the_states, and false otherwise.
348 *
349 * @param[in] the_states is the task state set to test
350 *
351 * @return This method returns true if the desired state condition is set.
352 */
353RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_time (
354  States_Control the_states
355)
356{
357   return (the_states & STATES_WAITING_FOR_TIME);
358}
359
360/**
361 * This function returns true if the WAITING_FOR_TIME state is set in
362 * the_states, and false otherwise.
363 *
364 * @param[in] the_states is the task state set to test
365 *
366 * @return This method returns true if the desired state condition is set.
367 */
368RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_rpc_reply (
369  States_Control the_states
370)
371{
372   return (the_states & STATES_WAITING_FOR_RPC_REPLY);
373}
374
375/**
376 * This function returns true if the WAITING_FOR_PERIOD state is set in
377 * the_states, and false otherwise.
378 *
379 * @param[in] the_states is the task state set to test
380 *
381 * @return This method returns true if the desired state condition is set.
382 */
383RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_period (
384  States_Control the_states
385)
386{
387   return (the_states & STATES_WAITING_FOR_PERIOD);
388}
389
390RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_join_at_exit(
391  States_Control the_states
392)
393{
394   return ( the_states & STATES_WAITING_FOR_JOIN_AT_EXIT ) != 0;
395}
396
397/**
398 * This function returns true if the task's state is set in
399 * way that allows it to be interrupted by a signal.
400 *
401 * @param[in] the_states is the task state set to test
402 *
403 * @return This method returns true if the desired state condition is set.
404 */
405RTEMS_INLINE_ROUTINE bool _States_Is_interruptible_by_signal (
406  States_Control the_states
407)
408{
409   return (the_states & STATES_INTERRUPTIBLE_BY_SIGNAL);
410
411}
412/**
413 * This function returns true if one of the states which indicates
414 * that a task is blocked waiting for a local resource is set in
415 * the_states, and false otherwise.
416 *
417 * @param[in] the_states is the task state set to test
418 *
419 * @return This method returns true if the desired state condition is set.
420 */
421
422RTEMS_INLINE_ROUTINE bool _States_Is_locally_blocked (
423  States_Control the_states
424)
425{
426   return (the_states & STATES_LOCALLY_BLOCKED);
427}
428
429/**
430 * This function returns true if one of the states which indicates
431 * that a task is blocked is set in the_states, and false otherwise.
432 *
433 * @param[in] the_states is the task state set to test
434 *
435 * @return This method returns true if the state indicates that the
436 *         assocated thread is blocked.
437 */
438RTEMS_INLINE_ROUTINE bool _States_Is_blocked (
439  States_Control the_states
440)
441{
442   return (the_states & STATES_BLOCKED);
443}
444
445/**
446 * This function returns true if any of the states in the mask
447 * are set in the_states, and false otherwise.
448 *
449 * @param[in] the_states is the task state set to test
450 * @param[in] mask is the state bits to test for
451 *
452 * @return This method returns true if the indicates state condition is set.
453 */
454RTEMS_INLINE_ROUTINE bool _States_Are_set (
455  States_Control the_states,
456  States_Control mask
457)
458{
459   return ( (the_states & mask) != STATES_READY);
460}
461
462/** @} */
463
464#ifdef __cplusplus
465}
466#endif
467
468#endif
469/* end of include file */
Note: See TracBrowser for help on using the repository browser.