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

5
Last change on this file since f78a5f5 was f78a5f5, checked in by Chris Johns <chrisj@…>, on 07/22/16 at 01:19:48

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
RevLine 
[1f0d013]1/**
2 * @file
3 *
4 * @brief Inlined Routines Associated with Thread State Information
[ac7d5ef0]5 *
[1f0d013]6 * This file contains the static inline implementation of the inlined
7 * routines associated with thread state information.
[baff4da]8 */
9
10/*
[b697bc6]11 *  COPYRIGHT (c) 1989-2012.
[ac7d5ef0]12 *  On-Line Applications Research Corporation (OAR).
13 *
[98e4ebf5]14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
[c499856]16 *  http://www.rtems.org/license/LICENSE.
[ac7d5ef0]17 */
18
[fe6c170c]19#ifndef _RTEMS_SCORE_STATESIMPL_H
20#define _RTEMS_SCORE_STATESIMPL_H
[ef49476]21
[fe6c170c]22#include <rtems/score/states.h>
23#include <rtems/score/basedefs.h>
[ac7d5ef0]24
[fe6c170c]25#ifdef __cplusplus
26extern "C" {
27#endif
[c5e2f7c]28
[baff4da]29/**
[1f0d013]30 * @addtogroup ScoreStates
[baff4da]31 */
[b697bc6]32/**@{**/
[baff4da]33
[fe6c170c]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
[b68cef17]77/** This macro corresponds to a task waiting for BSD wakeup. */
78#define STATES_WAITING_FOR_BSD_WAKEUP          0x80000
[f78a5f5]79/** This macro corresponds to a task being held by the debugger. */
80#define STATES_DEBUGGER                        0x100000
[1b1be254]81/** This macro corresponds to a task being a zombie. */
82#define STATES_ZOMBIE                          0x200000
[862a0ee]83/** This macro corresponds to a task those life is changing. */
84#define STATES_LIFE_IS_CHANGING                0x800000
[f329353]85/** This macro corresponds to a task waiting for a join. */
86#define STATES_WAITING_FOR_JOIN                0x1000000
[214d8ed]87/** This macro corresponds to a task waiting for a <sys/lock.h> mutex. */
88#define STATES_WAITING_FOR_SYS_LOCK_MUTEX      0x2000000
[7237b3e]89/** This macro corresponds to a task waiting for a <sys/lock.h> semaphore. */
90#define STATES_WAITING_FOR_SYS_LOCK_SEMAPHORE  0x4000000
[40188718]91/** This macro corresponds to a task waiting for a <sys/lock.h> futex. */
92#define STATES_WAITING_FOR_SYS_LOCK_FUTEX      0x8000000
[fe6c170c]93
94/** This macro corresponds to a task which is in an interruptible
95 *  blocking state.
96 */
97#define STATES_INTERRUPTIBLE_BY_SIGNAL         0x10000000
[9e9e61d]98/** This macro corresponds to a task waiting for a <sys/lock.h> condition. */
99#define STATES_WAITING_FOR_SYS_LOCK_CONDITION  0x20000000
[fe6c170c]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 | \
[f329353]108                                 STATES_WAITING_FOR_JOIN               | \
[fe6c170c]109                                 STATES_WAITING_FOR_SIGNAL             | \
110                                 STATES_WAITING_FOR_BARRIER            | \
[b68cef17]111                                 STATES_WAITING_FOR_BSD_WAKEUP         | \
[214d8ed]112                                 STATES_WAITING_FOR_SYS_LOCK_MUTEX     | \
[7237b3e]113                                 STATES_WAITING_FOR_SYS_LOCK_SEMAPHORE | \
[40188718]114                                 STATES_WAITING_FOR_SYS_LOCK_FUTEX     | \
[9e9e61d]115                                 STATES_WAITING_FOR_SYS_LOCK_CONDITION | \
[fe6c170c]116                                 STATES_WAITING_FOR_RWLOCK             )
117
118/** This macro corresponds to a task waiting which is blocked. */
119#define STATES_BLOCKED         ( STATES_DELAYING                | \
[56729d8]120                                 STATES_LOCALLY_BLOCKED         | \
[fe6c170c]121                                 STATES_WAITING_FOR_TIME        | \
122                                 STATES_WAITING_FOR_PERIOD      | \
123                                 STATES_WAITING_FOR_EVENT       | \
[56729d8]124                                 STATES_WAITING_FOR_RPC_REPLY   | \
[fe6c170c]125                                 STATES_WAITING_FOR_SYSTEM_EVENT | \
126                                 STATES_INTERRUPTIBLE_BY_SIGNAL )
127
[33829ce]128/** All state bits set to one (provided for _Thread_Start()) */
[1461aba8]129#define STATES_ALL_SET 0xffffffff
130
[baff4da]131/**
[1f0d013]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.
[cdea617]134 *
[1f0d013]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
[cdea617]137 *
[1f0d013]138 * @return This method returns the updated states value.
[ac7d5ef0]139 */
[503dc058]140RTEMS_INLINE_ROUTINE States_Control _States_Set (
[ac7d5ef0]141  States_Control states_to_set,
142  States_Control current_state
143)
144{
145   return (current_state | states_to_set);
146}
147
[baff4da]148/**
[1f0d013]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.
[cdea617]151 *
[e858f70]152 * @param[in] states_to_clear is the state bits to clean
[1f0d013]153 * @param[in] current_state is the state set to remove them from
[cdea617]154 *
[1f0d013]155 * @return This method returns the updated states value.
[ac7d5ef0]156 */
[503dc058]157RTEMS_INLINE_ROUTINE States_Control _States_Clear (
[ac7d5ef0]158  States_Control states_to_clear,
159  States_Control current_state
160)
161{
162   return (current_state & ~states_to_clear);
163}
164
[baff4da]165/**
[1f0d013]166 * This function returns true if the_states indicates that the
167 * state is READY, and false otherwise.
[cdea617]168 *
[1f0d013]169 * @param[in] the_states is the task state set to test
[cdea617]170 *
[1f0d013]171 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]172 */
[484a769]173RTEMS_INLINE_ROUTINE bool _States_Is_ready (
[ac7d5ef0]174  States_Control the_states
175)
176{
177   return (the_states == STATES_READY);
178}
179
[baff4da]180/**
[1f0d013]181 * This function returns true if the DORMANT state is the ONLY state
182 * set in the_states, and false otherwise.
[cdea617]183 *
[1f0d013]184 * @param[in] the_states is the task state set to test
[cdea617]185 *
[1f0d013]186 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]187 */
[484a769]188RTEMS_INLINE_ROUTINE bool _States_Is_only_dormant (
[ac7d5ef0]189  States_Control the_states
190)
191{
192   return (the_states == STATES_DORMANT);
193}
194
[baff4da]195/**
[1f0d013]196 * This function returns true if the DORMANT state is set in
197 * the_states, and false otherwise.
[cdea617]198 *
[1f0d013]199 * @param[in] the_states is the task state set to test
[cdea617]200 *
[1f0d013]201 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]202 */
[484a769]203RTEMS_INLINE_ROUTINE bool _States_Is_dormant (
[ac7d5ef0]204  States_Control the_states
205)
206{
207   return (the_states & STATES_DORMANT);
208}
209
[baff4da]210/**
[1f0d013]211 * This function returns true if the SUSPENDED state is set in
212 * the_states, and false otherwise.
[cdea617]213 *
[1f0d013]214 * @param[in] the_states is the task state set to test
[cdea617]215 *
[1f0d013]216 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]217 */
[484a769]218RTEMS_INLINE_ROUTINE bool _States_Is_suspended (
[ac7d5ef0]219  States_Control the_states
220)
221{
222   return (the_states & STATES_SUSPENDED);
223}
224
[baff4da]225/**
[1f0d013]226 * This function returns true if the DELAYING state is set in
227 * the_states, and false otherwise.
[cdea617]228 *
[1f0d013]229 * @param[in] the_states is the task state set to test
[cdea617]230 *
[1f0d013]231 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]232 */
[484a769]233RTEMS_INLINE_ROUTINE bool _States_Is_delaying (
[ac7d5ef0]234  States_Control the_states
235)
236{
237   return (the_states & STATES_DELAYING);
238}
239
[baff4da]240/**
[1f0d013]241 * This function returns true if the WAITING_FOR_BUFFER state is set in
242 * the_states, and false otherwise.
[cdea617]243 *
[1f0d013]244 * @param[in] the_states is the task state set to test
[cdea617]245 *
[1f0d013]246 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]247 */
[484a769]248RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_buffer (
[ac7d5ef0]249  States_Control the_states
250)
251{
252   return (the_states & STATES_WAITING_FOR_BUFFER);
253}
254
[baff4da]255/**
[1f0d013]256 * This function returns true if the WAITING_FOR_SEGMENT state is set in
257 * the_states, and false otherwise.
[cdea617]258 *
[1f0d013]259 * @param[in] the_states is the task state set to test
[cdea617]260 *
[1f0d013]261 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]262 */
[484a769]263RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_segment (
[ac7d5ef0]264  States_Control the_states
265)
266{
267   return (the_states & STATES_WAITING_FOR_SEGMENT);
268}
269
[baff4da]270/**
[1f0d013]271 * This function returns true if the WAITING_FOR_MESSAGE state is set in
272 * the_states, and false otherwise.
[cdea617]273 *
[1f0d013]274 * @param[in] the_states is the task state set to test
[cdea617]275 *
[1f0d013]276 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]277 */
[484a769]278RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_message (
[ac7d5ef0]279  States_Control the_states
280)
281{
282   return (the_states & STATES_WAITING_FOR_MESSAGE);
283}
284
[baff4da]285/**
[1f0d013]286 * This function returns true if the WAITING_FOR_EVENT state is set in
287 * the_states, and false otherwise.
[cdea617]288 *
[1f0d013]289 * @param[in] the_states is the task state set to test
[cdea617]290 *
[1f0d013]291 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]292 */
[484a769]293RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_event (
[ac7d5ef0]294  States_Control the_states
295)
296{
297   return (the_states & STATES_WAITING_FOR_EVENT);
298}
299
[0edf263]300/**
[1f0d013]301 * This function returns true if the WAITING_FOR_SYSTEM_EVENT state is set in
302 * the_states, and false otherwise.
[0edf263]303 *
[1f0d013]304 * @param[in] the_states is the task state set to test
[0edf263]305 *
[1f0d013]306 * @return This method returns true if the desired state condition is set.
[0edf263]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
[baff4da]315/**
[1f0d013]316 * This function returns true if the WAITING_FOR_MUTEX state
317 * is set in the_states, and false otherwise.
[cdea617]318 *
[1f0d013]319 * @param[in] the_states is the task state set to test
[cdea617]320 *
[1f0d013]321 * @return This method returns true if the desired state condition is set.
[3a4ae6c]322 */
[484a769]323RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_mutex (
[3a4ae6c]324  States_Control the_states
325)
326{
327   return (the_states & STATES_WAITING_FOR_MUTEX);
328}
329
[baff4da]330/**
[1f0d013]331 * This function returns true if the WAITING_FOR_SEMAPHORE state
332 * is set in the_states, and false otherwise.
[cdea617]333 *
[1f0d013]334 * @param[in] the_states is the task state set to test
[cdea617]335 *
[1f0d013]336 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]337 */
[484a769]338RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_semaphore (
[ac7d5ef0]339  States_Control the_states
340)
341{
342   return (the_states & STATES_WAITING_FOR_SEMAPHORE);
343}
344
[baff4da]345/**
[1f0d013]346 * This function returns true if the WAITING_FOR_TIME state is set in
347 * the_states, and false otherwise.
[cdea617]348 *
[1f0d013]349 * @param[in] the_states is the task state set to test
[cdea617]350 *
[1f0d013]351 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]352 */
[484a769]353RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_time (
[ac7d5ef0]354  States_Control the_states
355)
356{
357   return (the_states & STATES_WAITING_FOR_TIME);
358}
359
[baff4da]360/**
[1f0d013]361 * This function returns true if the WAITING_FOR_TIME state is set in
362 * the_states, and false otherwise.
[cdea617]363 *
[1f0d013]364 * @param[in] the_states is the task state set to test
[cdea617]365 *
[1f0d013]366 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]367 */
[484a769]368RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_rpc_reply (
[ac7d5ef0]369  States_Control the_states
370)
371{
372   return (the_states & STATES_WAITING_FOR_RPC_REPLY);
373}
374
[baff4da]375/**
[1f0d013]376 * This function returns true if the WAITING_FOR_PERIOD state is set in
377 * the_states, and false otherwise.
[cdea617]378 *
[1f0d013]379 * @param[in] the_states is the task state set to test
[cdea617]380 *
[1f0d013]381 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]382 */
[484a769]383RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_period (
[ac7d5ef0]384  States_Control the_states
385)
386{
387   return (the_states & STATES_WAITING_FOR_PERIOD);
388}
389
[54550e04]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
[cdea617]397/**
[1f0d013]398 * This function returns true if the task's state is set in
399 * way that allows it to be interrupted by a signal.
[cdea617]400 *
[1f0d013]401 * @param[in] the_states is the task state set to test
[cdea617]402 *
[1f0d013]403 * @return This method returns true if the desired state condition is set.
[cdea617]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}
[baff4da]412/**
[1f0d013]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.
[cdea617]416 *
[1f0d013]417 * @param[in] the_states is the task state set to test
[cdea617]418 *
[1f0d013]419 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]420 */
421
[484a769]422RTEMS_INLINE_ROUTINE bool _States_Is_locally_blocked (
[ac7d5ef0]423  States_Control the_states
424)
425{
426   return (the_states & STATES_LOCALLY_BLOCKED);
427}
428
[baff4da]429/**
[1f0d013]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.
[cdea617]432 *
[1f0d013]433 * @param[in] the_states is the task state set to test
[cdea617]434 *
[1f0d013]435 * @return This method returns true if the state indicates that the
436 *         assocated thread is blocked.
[ac7d5ef0]437 */
[484a769]438RTEMS_INLINE_ROUTINE bool _States_Is_blocked (
[ac7d5ef0]439  States_Control the_states
440)
441{
442   return (the_states & STATES_BLOCKED);
443}
444
[baff4da]445/**
[1f0d013]446 * This function returns true if any of the states in the mask
447 * are set in the_states, and false otherwise.
[cdea617]448 *
[1f0d013]449 * @param[in] the_states is the task state set to test
450 * @param[in] mask is the state bits to test for
[cdea617]451 *
[1f0d013]452 * @return This method returns true if the indicates state condition is set.
[ac7d5ef0]453 */
[484a769]454RTEMS_INLINE_ROUTINE bool _States_Are_set (
[ac7d5ef0]455  States_Control the_states,
456  States_Control mask
457)
458{
459   return ( (the_states & mask) != STATES_READY);
460}
461
[1f0d013]462/** @} */
[baff4da]463
[fe6c170c]464#ifdef __cplusplus
465}
466#endif
467
[ac7d5ef0]468#endif
469/* end of include file */
Note: See TracBrowser for help on using the repository browser.