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

5
Last change on this file since d063e7b3 was d063e7b3, checked in by Sebastian Huber <sebastian.huber@…>, on 01/11/17 at 07:42:04

score: Replace STATES_DELAYING

Replace STATES_DELAYING with STATES_WAITING_FOR_TIME.

There is no need for separate timeout thread states. The
Thread_Control::Timer::header and Watchdog_Control::cpu members can be
used to figure out the kind of timeout.

  • Property mode set to 100644
File size: 13.3 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
[4e07d9b3]36 *  be used to compose and manipulate a thread's state.  More frequently used
37 *  states should use lower value bits to ease the use of immediate values on
38 *  RISC architectures.
[fe6c170c]39 */
40
41/** This macro corresponds to a task being ready. */
[2e6d9865]42#define STATES_READY                           0x00000000
[4e07d9b3]43
44/**
45 * @brief This macro corresponds to a task which is blocked on a thread queue
46 * embedded in an object with an identifier.
47 *
48 * This thread state bit is intended to ease debugging and improve system
49 * diagnostics, see _Thread_Wait_get_id().
50 */
51#define STATES_THREAD_QUEUE_WITH_IDENTIFIER    0x00000001
52
[fe6c170c]53/** This macro corresponds to a task waiting for a mutex. */
[4e07d9b3]54#define STATES_WAITING_FOR_MUTEX               0x00000002
55
56/** This macro corresponds to a task waiting for a semaphore. */
57#define STATES_WAITING_FOR_SEMAPHORE           0x00000004
58
59/** This macro corresponds to a task waiting for an event. */
60#define STATES_WAITING_FOR_EVENT               0x00000008
61
62/** This macro corresponds to a task waiting for a system event. */
63#define STATES_WAITING_FOR_SYSTEM_EVENT        0x00000010
64
65/** This macro corresponds to a task waiting for a message. */
66#define STATES_WAITING_FOR_MESSAGE             0x00000020
67
[fe6c170c]68/** This macro corresponds to a task waiting for a condition variable. */
[4e07d9b3]69#define STATES_WAITING_FOR_CONDITION_VARIABLE  0x00000040
70
71/** This macro corresponds to a task waiting for a futex. */
72#define STATES_WAITING_FOR_FUTEX               0x00000080
73
74/** This macro corresponds to a task waiting for BSD wakeup. */
75#define STATES_WAITING_FOR_BSD_WAKEUP          0x00000100
76
[d063e7b3]77/**
78 * @brief This macro corresponds to a task which is waiting for a relative or
79 * absolute timeout.
80 */
81#define STATES_WAITING_FOR_TIME                0x00000200
[4e07d9b3]82
[fe6c170c]83/** This macro corresponds to a task waiting for a period. */
[4e07d9b3]84#define STATES_WAITING_FOR_PERIOD              0x00000400
85
[fe6c170c]86/** This macro corresponds to a task waiting for a signal. */
[4e07d9b3]87#define STATES_WAITING_FOR_SIGNAL              0x00000800
88
[fe6c170c]89/** This macro corresponds to a task waiting for a barrier. */
[4e07d9b3]90#define STATES_WAITING_FOR_BARRIER             0x00001000
91
[fe6c170c]92/** This macro corresponds to a task waiting for a RWLock. */
[4e07d9b3]93#define STATES_WAITING_FOR_RWLOCK              0x00002000
94
95/** This macro corresponds to a task waiting for a join while exiting. */
96#define STATES_WAITING_FOR_JOIN_AT_EXIT        0x00004000
97
[f329353]98/** This macro corresponds to a task waiting for a join. */
[4e07d9b3]99#define STATES_WAITING_FOR_JOIN                0x00008000
100
101/** This macro corresponds to a task being suspended. */
102#define STATES_SUSPENDED                       0x00010000
103
104/** This macro corresponds to a task waiting for a fixed size segment. */
105#define STATES_WAITING_FOR_SEGMENT             0x00020000
106
107/** This macro corresponds to a task those life is changing. */
108#define STATES_LIFE_IS_CHANGING                0x00040000
109
110/** This macro corresponds to a task being held by the debugger. */
111#define STATES_DEBUGGER                        0x08000000
[fe6c170c]112
113/** This macro corresponds to a task which is in an interruptible
114 *  blocking state.
115 */
116#define STATES_INTERRUPTIBLE_BY_SIGNAL         0x10000000
[9a448aab]117
[4e07d9b3]118/** This macro corresponds to a task waiting for a reply to an MPCI request. */
119#define STATES_WAITING_FOR_RPC_REPLY           0x20000000
120
121/** This macro corresponds to a task being a zombie. */
122#define STATES_ZOMBIE                          0x40000000
123
124/** This macro corresponds to a task being created but not yet started. */
125#define STATES_DORMANT                         0x80000000
[fe6c170c]126
127/** This macro corresponds to a task waiting for a local object operation. */
[9a448aab]128#define STATES_LOCALLY_BLOCKED ( STATES_THREAD_QUEUE_WITH_IDENTIFIER   | \
129                                 STATES_WAITING_FOR_SEGMENT            | \
[fe6c170c]130                                 STATES_WAITING_FOR_MESSAGE            | \
131                                 STATES_WAITING_FOR_SEMAPHORE          | \
132                                 STATES_WAITING_FOR_MUTEX              | \
133                                 STATES_WAITING_FOR_CONDITION_VARIABLE | \
[f329353]134                                 STATES_WAITING_FOR_JOIN               | \
[fe6c170c]135                                 STATES_WAITING_FOR_SIGNAL             | \
136                                 STATES_WAITING_FOR_BARRIER            | \
[b68cef17]137                                 STATES_WAITING_FOR_BSD_WAKEUP         | \
[9a448aab]138                                 STATES_WAITING_FOR_FUTEX              | \
[fe6c170c]139                                 STATES_WAITING_FOR_RWLOCK             )
140
141/** This macro corresponds to a task waiting which is blocked. */
[d063e7b3]142#define STATES_BLOCKED         ( STATES_LOCALLY_BLOCKED         | \
[fe6c170c]143                                 STATES_WAITING_FOR_TIME        | \
144                                 STATES_WAITING_FOR_PERIOD      | \
145                                 STATES_WAITING_FOR_EVENT       | \
[56729d8]146                                 STATES_WAITING_FOR_RPC_REPLY   | \
[fe6c170c]147                                 STATES_WAITING_FOR_SYSTEM_EVENT | \
148                                 STATES_INTERRUPTIBLE_BY_SIGNAL )
149
[33829ce]150/** All state bits set to one (provided for _Thread_Start()) */
[1461aba8]151#define STATES_ALL_SET 0xffffffff
152
[baff4da]153/**
[1f0d013]154 * This function sets the given states_to_set into the current_state
155 * passed in.  The result is returned to the user in current_state.
[cdea617]156 *
[1f0d013]157 * @param[in] states_to_set is the state bits to set
158 * @param[in] current_state is the state set to add them to
[cdea617]159 *
[1f0d013]160 * @return This method returns the updated states value.
[ac7d5ef0]161 */
[503dc058]162RTEMS_INLINE_ROUTINE States_Control _States_Set (
[ac7d5ef0]163  States_Control states_to_set,
164  States_Control current_state
165)
166{
167   return (current_state | states_to_set);
168}
169
[baff4da]170/**
[1f0d013]171 * This function clears the given states_to_clear into the current_state
172 * passed in.  The result is returned to the user in current_state.
[cdea617]173 *
[e858f70]174 * @param[in] states_to_clear is the state bits to clean
[1f0d013]175 * @param[in] current_state is the state set to remove them from
[cdea617]176 *
[1f0d013]177 * @return This method returns the updated states value.
[ac7d5ef0]178 */
[503dc058]179RTEMS_INLINE_ROUTINE States_Control _States_Clear (
[ac7d5ef0]180  States_Control states_to_clear,
181  States_Control current_state
182)
183{
184   return (current_state & ~states_to_clear);
185}
186
[baff4da]187/**
[1f0d013]188 * This function returns true if the_states indicates that the
189 * state is READY, and false otherwise.
[cdea617]190 *
[1f0d013]191 * @param[in] the_states is the task state set to test
[cdea617]192 *
[1f0d013]193 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]194 */
[484a769]195RTEMS_INLINE_ROUTINE bool _States_Is_ready (
[ac7d5ef0]196  States_Control the_states
197)
198{
199   return (the_states == STATES_READY);
200}
201
[baff4da]202/**
[1f0d013]203 * This function returns true if the DORMANT state is the ONLY state
204 * set in the_states, and false otherwise.
[cdea617]205 *
[1f0d013]206 * @param[in] the_states is the task state set to test
[cdea617]207 *
[1f0d013]208 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]209 */
[484a769]210RTEMS_INLINE_ROUTINE bool _States_Is_only_dormant (
[ac7d5ef0]211  States_Control the_states
212)
213{
214   return (the_states == STATES_DORMANT);
215}
216
[baff4da]217/**
[1f0d013]218 * This function returns true if the DORMANT state is set in
219 * the_states, and false otherwise.
[cdea617]220 *
[1f0d013]221 * @param[in] the_states is the task state set to test
[cdea617]222 *
[1f0d013]223 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]224 */
[484a769]225RTEMS_INLINE_ROUTINE bool _States_Is_dormant (
[ac7d5ef0]226  States_Control the_states
227)
228{
229   return (the_states & STATES_DORMANT);
230}
231
[baff4da]232/**
[1f0d013]233 * This function returns true if the SUSPENDED state is set in
234 * the_states, and false otherwise.
[cdea617]235 *
[1f0d013]236 * @param[in] the_states is the task state set to test
[cdea617]237 *
[1f0d013]238 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]239 */
[484a769]240RTEMS_INLINE_ROUTINE bool _States_Is_suspended (
[ac7d5ef0]241  States_Control the_states
242)
243{
244   return (the_states & STATES_SUSPENDED);
245}
246
[baff4da]247/**
[1f0d013]248 * This function returns true if the WAITING_FOR_SEGMENT state is set in
249 * the_states, and false otherwise.
[cdea617]250 *
[1f0d013]251 * @param[in] the_states is the task state set to test
[cdea617]252 *
[1f0d013]253 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]254 */
[484a769]255RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_segment (
[ac7d5ef0]256  States_Control the_states
257)
258{
259   return (the_states & STATES_WAITING_FOR_SEGMENT);
260}
261
[baff4da]262/**
[1f0d013]263 * This function returns true if the WAITING_FOR_MESSAGE state is set in
264 * the_states, and false otherwise.
[cdea617]265 *
[1f0d013]266 * @param[in] the_states is the task state set to test
[cdea617]267 *
[1f0d013]268 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]269 */
[484a769]270RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_message (
[ac7d5ef0]271  States_Control the_states
272)
273{
274   return (the_states & STATES_WAITING_FOR_MESSAGE);
275}
276
[baff4da]277/**
[1f0d013]278 * This function returns true if the WAITING_FOR_EVENT state is set in
279 * the_states, and false otherwise.
[cdea617]280 *
[1f0d013]281 * @param[in] the_states is the task state set to test
[cdea617]282 *
[1f0d013]283 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]284 */
[484a769]285RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_event (
[ac7d5ef0]286  States_Control the_states
287)
288{
289   return (the_states & STATES_WAITING_FOR_EVENT);
290}
291
[0edf263]292/**
[1f0d013]293 * This function returns true if the WAITING_FOR_SYSTEM_EVENT state is set in
294 * the_states, and false otherwise.
[0edf263]295 *
[1f0d013]296 * @param[in] the_states is the task state set to test
[0edf263]297 *
[1f0d013]298 * @return This method returns true if the desired state condition is set.
[0edf263]299 */
300RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_system_event (
301  States_Control the_states
302)
303{
304   return (the_states & STATES_WAITING_FOR_SYSTEM_EVENT);
305}
306
[baff4da]307/**
[1f0d013]308 * This function returns true if the WAITING_FOR_MUTEX state
309 * is set in the_states, and false otherwise.
[cdea617]310 *
[1f0d013]311 * @param[in] the_states is the task state set to test
[cdea617]312 *
[1f0d013]313 * @return This method returns true if the desired state condition is set.
[3a4ae6c]314 */
[484a769]315RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_mutex (
[3a4ae6c]316  States_Control the_states
317)
318{
319   return (the_states & STATES_WAITING_FOR_MUTEX);
320}
321
[baff4da]322/**
[1f0d013]323 * This function returns true if the WAITING_FOR_SEMAPHORE state
324 * is set in the_states, and false otherwise.
[cdea617]325 *
[1f0d013]326 * @param[in] the_states is the task state set to test
[cdea617]327 *
[1f0d013]328 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]329 */
[484a769]330RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_semaphore (
[ac7d5ef0]331  States_Control the_states
332)
333{
334   return (the_states & STATES_WAITING_FOR_SEMAPHORE);
335}
336
[baff4da]337/**
[1f0d013]338 * This function returns true if the WAITING_FOR_TIME state is set in
339 * the_states, and false otherwise.
[cdea617]340 *
[1f0d013]341 * @param[in] the_states is the task state set to test
[cdea617]342 *
[1f0d013]343 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]344 */
[484a769]345RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_rpc_reply (
[ac7d5ef0]346  States_Control the_states
347)
348{
349   return (the_states & STATES_WAITING_FOR_RPC_REPLY);
350}
351
[baff4da]352/**
[1f0d013]353 * This function returns true if the WAITING_FOR_PERIOD state is set in
354 * the_states, and false otherwise.
[cdea617]355 *
[1f0d013]356 * @param[in] the_states is the task state set to test
[cdea617]357 *
[1f0d013]358 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]359 */
[484a769]360RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_period (
[ac7d5ef0]361  States_Control the_states
362)
363{
364   return (the_states & STATES_WAITING_FOR_PERIOD);
365}
366
[54550e04]367RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_join_at_exit(
368  States_Control the_states
369)
370{
371   return ( the_states & STATES_WAITING_FOR_JOIN_AT_EXIT ) != 0;
372}
373
[cdea617]374/**
[1f0d013]375 * This function returns true if the task's state is set in
376 * way that allows it to be interrupted by a signal.
[cdea617]377 *
[1f0d013]378 * @param[in] the_states is the task state set to test
[cdea617]379 *
[1f0d013]380 * @return This method returns true if the desired state condition is set.
[cdea617]381 */
382RTEMS_INLINE_ROUTINE bool _States_Is_interruptible_by_signal (
383  States_Control the_states
384)
385{
386   return (the_states & STATES_INTERRUPTIBLE_BY_SIGNAL);
387
388}
[baff4da]389/**
[1f0d013]390 * This function returns true if one of the states which indicates
391 * that a task is blocked waiting for a local resource is set in
392 * the_states, and false otherwise.
[cdea617]393 *
[1f0d013]394 * @param[in] the_states is the task state set to test
[cdea617]395 *
[1f0d013]396 * @return This method returns true if the desired state condition is set.
[ac7d5ef0]397 */
398
[484a769]399RTEMS_INLINE_ROUTINE bool _States_Is_locally_blocked (
[ac7d5ef0]400  States_Control the_states
401)
402{
403   return (the_states & STATES_LOCALLY_BLOCKED);
404}
405
[baff4da]406/**
[1f0d013]407 * This function returns true if one of the states which indicates
408 * that a task is blocked is set in the_states, and false otherwise.
[cdea617]409 *
[1f0d013]410 * @param[in] the_states is the task state set to test
[cdea617]411 *
[1f0d013]412 * @return This method returns true if the state indicates that the
413 *         assocated thread is blocked.
[ac7d5ef0]414 */
[484a769]415RTEMS_INLINE_ROUTINE bool _States_Is_blocked (
[ac7d5ef0]416  States_Control the_states
417)
418{
419   return (the_states & STATES_BLOCKED);
420}
421
[baff4da]422/**
[1f0d013]423 * This function returns true if any of the states in the mask
424 * are set in the_states, and false otherwise.
[cdea617]425 *
[1f0d013]426 * @param[in] the_states is the task state set to test
427 * @param[in] mask is the state bits to test for
[cdea617]428 *
[1f0d013]429 * @return This method returns true if the indicates state condition is set.
[ac7d5ef0]430 */
[484a769]431RTEMS_INLINE_ROUTINE bool _States_Are_set (
[ac7d5ef0]432  States_Control the_states,
433  States_Control mask
434)
435{
436   return ( (the_states & mask) != STATES_READY);
437}
438
[1f0d013]439/** @} */
[baff4da]440
[fe6c170c]441#ifdef __cplusplus
442}
443#endif
444
[ac7d5ef0]445#endif
446/* end of include file */
Note: See TracBrowser for help on using the repository browser.