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 Jan 11, 2017 at 7:42:04 AM

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
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/**
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
53/** This macro corresponds to a task waiting for a mutex. */
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
68/** This macro corresponds to a task waiting for a condition variable. */
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
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
82
83/** This macro corresponds to a task waiting for a period. */
84#define STATES_WAITING_FOR_PERIOD              0x00000400
85
86/** This macro corresponds to a task waiting for a signal. */
87#define STATES_WAITING_FOR_SIGNAL              0x00000800
88
89/** This macro corresponds to a task waiting for a barrier. */
90#define STATES_WAITING_FOR_BARRIER             0x00001000
91
92/** This macro corresponds to a task waiting for a RWLock. */
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
98/** This macro corresponds to a task waiting for a join. */
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
112
113/** This macro corresponds to a task which is in an interruptible
114 *  blocking state.
115 */
116#define STATES_INTERRUPTIBLE_BY_SIGNAL         0x10000000
117
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
126
127/** This macro corresponds to a task waiting for a local object operation. */
128#define STATES_LOCALLY_BLOCKED ( STATES_THREAD_QUEUE_WITH_IDENTIFIER   | \
129                                 STATES_WAITING_FOR_SEGMENT            | \
130                                 STATES_WAITING_FOR_MESSAGE            | \
131                                 STATES_WAITING_FOR_SEMAPHORE          | \
132                                 STATES_WAITING_FOR_MUTEX              | \
133                                 STATES_WAITING_FOR_CONDITION_VARIABLE | \
134                                 STATES_WAITING_FOR_JOIN               | \
135                                 STATES_WAITING_FOR_SIGNAL             | \
136                                 STATES_WAITING_FOR_BARRIER            | \
137                                 STATES_WAITING_FOR_BSD_WAKEUP         | \
138                                 STATES_WAITING_FOR_FUTEX              | \
139                                 STATES_WAITING_FOR_RWLOCK             )
140
141/** This macro corresponds to a task waiting which is blocked. */
142#define STATES_BLOCKED         ( STATES_LOCALLY_BLOCKED         | \
143                                 STATES_WAITING_FOR_TIME        | \
144                                 STATES_WAITING_FOR_PERIOD      | \
145                                 STATES_WAITING_FOR_EVENT       | \
146                                 STATES_WAITING_FOR_RPC_REPLY   | \
147                                 STATES_WAITING_FOR_SYSTEM_EVENT | \
148                                 STATES_INTERRUPTIBLE_BY_SIGNAL )
149
150/** All state bits set to one (provided for _Thread_Start()) */
151#define STATES_ALL_SET 0xffffffff
152
153/**
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.
156 *
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
159 *
160 * @return This method returns the updated states value.
161 */
162RTEMS_INLINE_ROUTINE States_Control _States_Set (
163  States_Control states_to_set,
164  States_Control current_state
165)
166{
167   return (current_state | states_to_set);
168}
169
170/**
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.
173 *
174 * @param[in] states_to_clear is the state bits to clean
175 * @param[in] current_state is the state set to remove them from
176 *
177 * @return This method returns the updated states value.
178 */
179RTEMS_INLINE_ROUTINE States_Control _States_Clear (
180  States_Control states_to_clear,
181  States_Control current_state
182)
183{
184   return (current_state & ~states_to_clear);
185}
186
187/**
188 * This function returns true if the_states indicates that the
189 * state is READY, and false otherwise.
190 *
191 * @param[in] the_states is the task state set to test
192 *
193 * @return This method returns true if the desired state condition is set.
194 */
195RTEMS_INLINE_ROUTINE bool _States_Is_ready (
196  States_Control the_states
197)
198{
199   return (the_states == STATES_READY);
200}
201
202/**
203 * This function returns true if the DORMANT state is the ONLY state
204 * set in the_states, and false otherwise.
205 *
206 * @param[in] the_states is the task state set to test
207 *
208 * @return This method returns true if the desired state condition is set.
209 */
210RTEMS_INLINE_ROUTINE bool _States_Is_only_dormant (
211  States_Control the_states
212)
213{
214   return (the_states == STATES_DORMANT);
215}
216
217/**
218 * This function returns true if the DORMANT state is set in
219 * the_states, and false otherwise.
220 *
221 * @param[in] the_states is the task state set to test
222 *
223 * @return This method returns true if the desired state condition is set.
224 */
225RTEMS_INLINE_ROUTINE bool _States_Is_dormant (
226  States_Control the_states
227)
228{
229   return (the_states & STATES_DORMANT);
230}
231
232/**
233 * This function returns true if the SUSPENDED state is set in
234 * the_states, and false otherwise.
235 *
236 * @param[in] the_states is the task state set to test
237 *
238 * @return This method returns true if the desired state condition is set.
239 */
240RTEMS_INLINE_ROUTINE bool _States_Is_suspended (
241  States_Control the_states
242)
243{
244   return (the_states & STATES_SUSPENDED);
245}
246
247/**
248 * This function returns true if the WAITING_FOR_SEGMENT state is set in
249 * the_states, and false otherwise.
250 *
251 * @param[in] the_states is the task state set to test
252 *
253 * @return This method returns true if the desired state condition is set.
254 */
255RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_segment (
256  States_Control the_states
257)
258{
259   return (the_states & STATES_WAITING_FOR_SEGMENT);
260}
261
262/**
263 * This function returns true if the WAITING_FOR_MESSAGE state is set in
264 * the_states, and false otherwise.
265 *
266 * @param[in] the_states is the task state set to test
267 *
268 * @return This method returns true if the desired state condition is set.
269 */
270RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_message (
271  States_Control the_states
272)
273{
274   return (the_states & STATES_WAITING_FOR_MESSAGE);
275}
276
277/**
278 * This function returns true if the WAITING_FOR_EVENT state is set in
279 * the_states, and false otherwise.
280 *
281 * @param[in] the_states is the task state set to test
282 *
283 * @return This method returns true if the desired state condition is set.
284 */
285RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_event (
286  States_Control the_states
287)
288{
289   return (the_states & STATES_WAITING_FOR_EVENT);
290}
291
292/**
293 * This function returns true if the WAITING_FOR_SYSTEM_EVENT state is set in
294 * the_states, and false otherwise.
295 *
296 * @param[in] the_states is the task state set to test
297 *
298 * @return This method returns true if the desired state condition is set.
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
307/**
308 * This function returns true if the WAITING_FOR_MUTEX state
309 * is set in the_states, and false otherwise.
310 *
311 * @param[in] the_states is the task state set to test
312 *
313 * @return This method returns true if the desired state condition is set.
314 */
315RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_mutex (
316  States_Control the_states
317)
318{
319   return (the_states & STATES_WAITING_FOR_MUTEX);
320}
321
322/**
323 * This function returns true if the WAITING_FOR_SEMAPHORE state
324 * is set in the_states, and false otherwise.
325 *
326 * @param[in] the_states is the task state set to test
327 *
328 * @return This method returns true if the desired state condition is set.
329 */
330RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_semaphore (
331  States_Control the_states
332)
333{
334   return (the_states & STATES_WAITING_FOR_SEMAPHORE);
335}
336
337/**
338 * This function returns true if the WAITING_FOR_TIME state is set in
339 * the_states, and false otherwise.
340 *
341 * @param[in] the_states is the task state set to test
342 *
343 * @return This method returns true if the desired state condition is set.
344 */
345RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_rpc_reply (
346  States_Control the_states
347)
348{
349   return (the_states & STATES_WAITING_FOR_RPC_REPLY);
350}
351
352/**
353 * This function returns true if the WAITING_FOR_PERIOD state is set in
354 * the_states, and false otherwise.
355 *
356 * @param[in] the_states is the task state set to test
357 *
358 * @return This method returns true if the desired state condition is set.
359 */
360RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_period (
361  States_Control the_states
362)
363{
364   return (the_states & STATES_WAITING_FOR_PERIOD);
365}
366
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
374/**
375 * This function returns true if the task's state is set in
376 * way that allows it to be interrupted by a signal.
377 *
378 * @param[in] the_states is the task state set to test
379 *
380 * @return This method returns true if the desired state condition is set.
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}
389/**
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.
393 *
394 * @param[in] the_states is the task state set to test
395 *
396 * @return This method returns true if the desired state condition is set.
397 */
398
399RTEMS_INLINE_ROUTINE bool _States_Is_locally_blocked (
400  States_Control the_states
401)
402{
403   return (the_states & STATES_LOCALLY_BLOCKED);
404}
405
406/**
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.
409 *
410 * @param[in] the_states is the task state set to test
411 *
412 * @return This method returns true if the state indicates that the
413 *         assocated thread is blocked.
414 */
415RTEMS_INLINE_ROUTINE bool _States_Is_blocked (
416  States_Control the_states
417)
418{
419   return (the_states & STATES_BLOCKED);
420}
421
422/**
423 * This function returns true if any of the states in the mask
424 * are set in the_states, and false otherwise.
425 *
426 * @param[in] the_states is the task state set to test
427 * @param[in] mask is the state bits to test for
428 *
429 * @return This method returns true if the indicates state condition is set.
430 */
431RTEMS_INLINE_ROUTINE bool _States_Are_set (
432  States_Control the_states,
433  States_Control mask
434)
435{
436   return ( (the_states & mask) != STATES_READY);
437}
438
439/** @} */
440
441#ifdef __cplusplus
442}
443#endif
444
445#endif
446/* end of include file */
Note: See TracBrowser for help on using the repository browser.