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

5
Last change on this file since e366f77 was e366f77, checked in by Sebastian Huber <sebastian.huber@…>, on 01/31/17 at 07:08:24

score: Add _Thread_queue_Object_name

Add the special thread queue name _Thread_queue_Object_name to mark
thread queues embedded in an object with identifier. Using the special
thread state STATES_THREAD_QUEUE_WITH_IDENTIFIER is not reliable for
this purpose since the thread wait information and thread state are
protected by different SMP locks in separate critical sections. Remove
STATES_THREAD_QUEUE_WITH_IDENTIFIER.

Add and use _Thread_queue_Object_initialize().

Update #2858.

  • Property mode set to 100644
File size: 8.9 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.  More frequently used
37 *  states should use lower value bits to ease the use of immediate values on
38 *  RISC architectures.
39 */
40
41/** This macro corresponds to a task being ready. */
42#define STATES_READY                           0x00000000
43
44/** This macro corresponds to a task waiting for a mutex. */
45#define STATES_WAITING_FOR_MUTEX               0x00000001
46
47/** This macro corresponds to a task waiting for a semaphore. */
48#define STATES_WAITING_FOR_SEMAPHORE           0x00000002
49
50/** This macro corresponds to a task waiting for an event. */
51#define STATES_WAITING_FOR_EVENT               0x00000004
52
53/** This macro corresponds to a task waiting for a system event. */
54#define STATES_WAITING_FOR_SYSTEM_EVENT        0x00000008
55
56/** This macro corresponds to a task waiting for a message. */
57#define STATES_WAITING_FOR_MESSAGE             0x00000010
58
59/** This macro corresponds to a task waiting for a condition variable. */
60#define STATES_WAITING_FOR_CONDITION_VARIABLE  0x00000020
61
62/** This macro corresponds to a task waiting for a futex. */
63#define STATES_WAITING_FOR_FUTEX               0x00000040
64
65/** This macro corresponds to a task waiting for BSD wakeup. */
66#define STATES_WAITING_FOR_BSD_WAKEUP          0x00000080
67
68/**
69 * @brief This macro corresponds to a task which is waiting for a relative or
70 * absolute timeout.
71 */
72#define STATES_WAITING_FOR_TIME                0x00000100
73
74/** This macro corresponds to a task waiting for a period. */
75#define STATES_WAITING_FOR_PERIOD              0x00000200
76
77/** This macro corresponds to a task waiting for a signal. */
78#define STATES_WAITING_FOR_SIGNAL              0x00000400
79
80/** This macro corresponds to a task waiting for a barrier. */
81#define STATES_WAITING_FOR_BARRIER             0x00000800
82
83/** This macro corresponds to a task waiting for a RWLock. */
84#define STATES_WAITING_FOR_RWLOCK              0x00001000
85
86/** This macro corresponds to a task waiting for a join while exiting. */
87#define STATES_WAITING_FOR_JOIN_AT_EXIT        0x00002000
88
89/** This macro corresponds to a task waiting for a join. */
90#define STATES_WAITING_FOR_JOIN                0x00004000
91
92/** This macro corresponds to a task being suspended. */
93#define STATES_SUSPENDED                       0x00008000
94
95/** This macro corresponds to a task waiting for a fixed size segment. */
96#define STATES_WAITING_FOR_SEGMENT             0x00010000
97
98/** This macro corresponds to a task those life is changing. */
99#define STATES_LIFE_IS_CHANGING                0x00020000
100
101/** This macro corresponds to a task being held by the debugger. */
102#define STATES_DEBUGGER                        0x08000000
103
104/** This macro corresponds to a task which is in an interruptible
105 *  blocking state.
106 */
107#define STATES_INTERRUPTIBLE_BY_SIGNAL         0x10000000
108
109/** This macro corresponds to a task waiting for a reply to an MPCI request. */
110#define STATES_WAITING_FOR_RPC_REPLY           0x20000000
111
112/** This macro corresponds to a task being a zombie. */
113#define STATES_ZOMBIE                          0x40000000
114
115/** This macro corresponds to a task being created but not yet started. */
116#define STATES_DORMANT                         0x80000000
117
118/** This macro corresponds to a task waiting for a local object operation. */
119#define STATES_LOCALLY_BLOCKED ( STATES_WAITING_FOR_SEGMENT            | \
120                                 STATES_WAITING_FOR_MESSAGE            | \
121                                 STATES_WAITING_FOR_SEMAPHORE          | \
122                                 STATES_WAITING_FOR_MUTEX              | \
123                                 STATES_WAITING_FOR_CONDITION_VARIABLE | \
124                                 STATES_WAITING_FOR_JOIN               | \
125                                 STATES_WAITING_FOR_SIGNAL             | \
126                                 STATES_WAITING_FOR_BARRIER            | \
127                                 STATES_WAITING_FOR_BSD_WAKEUP         | \
128                                 STATES_WAITING_FOR_FUTEX              | \
129                                 STATES_WAITING_FOR_RWLOCK             )
130
131/** This macro corresponds to a task waiting which is blocked. */
132#define STATES_BLOCKED         ( STATES_LOCALLY_BLOCKED         | \
133                                 STATES_WAITING_FOR_TIME        | \
134                                 STATES_WAITING_FOR_PERIOD      | \
135                                 STATES_WAITING_FOR_EVENT       | \
136                                 STATES_WAITING_FOR_RPC_REPLY   | \
137                                 STATES_WAITING_FOR_SYSTEM_EVENT | \
138                                 STATES_INTERRUPTIBLE_BY_SIGNAL )
139
140/** All state bits set to one (provided for _Thread_Start()) */
141#define STATES_ALL_SET 0xffffffff
142
143/**
144 * This function sets the given states_to_set into the current_state
145 * passed in.  The result is returned to the user in current_state.
146 *
147 * @param[in] states_to_set is the state bits to set
148 * @param[in] current_state is the state set to add them to
149 *
150 * @return This method returns the updated states value.
151 */
152RTEMS_INLINE_ROUTINE States_Control _States_Set (
153  States_Control states_to_set,
154  States_Control current_state
155)
156{
157   return (current_state | states_to_set);
158}
159
160/**
161 * This function clears the given states_to_clear into the current_state
162 * passed in.  The result is returned to the user in current_state.
163 *
164 * @param[in] states_to_clear is the state bits to clean
165 * @param[in] current_state is the state set to remove them from
166 *
167 * @return This method returns the updated states value.
168 */
169RTEMS_INLINE_ROUTINE States_Control _States_Clear (
170  States_Control states_to_clear,
171  States_Control current_state
172)
173{
174   return (current_state & ~states_to_clear);
175}
176
177/**
178 * This function returns true if the_states indicates that the
179 * state is READY, and false otherwise.
180 *
181 * @param[in] the_states is the task state set to test
182 *
183 * @return This method returns true if the desired state condition is set.
184 */
185RTEMS_INLINE_ROUTINE bool _States_Is_ready (
186  States_Control the_states
187)
188{
189   return (the_states == STATES_READY);
190}
191
192/**
193 * This function returns true if the DORMANT state is set in
194 * the_states, and false otherwise.
195 *
196 * @param[in] the_states is the task state set to test
197 *
198 * @return This method returns true if the desired state condition is set.
199 */
200RTEMS_INLINE_ROUTINE bool _States_Is_dormant (
201  States_Control the_states
202)
203{
204   return (the_states & STATES_DORMANT);
205}
206
207/**
208 * This function returns true if the SUSPENDED state is set in
209 * the_states, and false otherwise.
210 *
211 * @param[in] the_states is the task state set to test
212 *
213 * @return This method returns true if the desired state condition is set.
214 */
215RTEMS_INLINE_ROUTINE bool _States_Is_suspended (
216  States_Control the_states
217)
218{
219   return (the_states & STATES_SUSPENDED);
220}
221
222/**
223 * This function returns true if the WAITING_FOR_TIME state is set in
224 * the_states, and false otherwise.
225 *
226 * @param[in] the_states is the task state set to test
227 *
228 * @return This method returns true if the desired state condition is set.
229 */
230RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_rpc_reply (
231  States_Control the_states
232)
233{
234   return (the_states & STATES_WAITING_FOR_RPC_REPLY);
235}
236
237RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_join_at_exit(
238  States_Control the_states
239)
240{
241   return ( the_states & STATES_WAITING_FOR_JOIN_AT_EXIT ) != 0;
242}
243
244/**
245 * This function returns true if the task's state is set in
246 * way that allows it to be interrupted by a signal.
247 *
248 * @param[in] the_states is the task state set to test
249 *
250 * @return This method returns true if the desired state condition is set.
251 */
252RTEMS_INLINE_ROUTINE bool _States_Is_interruptible_by_signal (
253  States_Control the_states
254)
255{
256   return (the_states & STATES_INTERRUPTIBLE_BY_SIGNAL);
257
258}
259/**
260 * This function returns true if one of the states which indicates
261 * that a task is blocked waiting for a local resource 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
269RTEMS_INLINE_ROUTINE bool _States_Is_locally_blocked (
270  States_Control the_states
271)
272{
273   return (the_states & STATES_LOCALLY_BLOCKED);
274}
275
276/** @} */
277
278#ifdef __cplusplus
279}
280#endif
281
282#endif
283/* end of include file */
Note: See TracBrowser for help on using the repository browser.