![]() |
|
|||
File indexing completed on 2025-05-11 08:24:13
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSScoreStates 0007 * 0008 * @brief This header file provides interfaces of the 0009 * @ref RTEMSScoreStates which are only used by the implementation. 0010 */ 0011 0012 /* 0013 * COPYRIGHT (c) 1989-2012. 0014 * On-Line Applications Research Corporation (OAR). 0015 * 0016 * Redistribution and use in source and binary forms, with or without 0017 * modification, are permitted provided that the following conditions 0018 * are met: 0019 * 1. Redistributions of source code must retain the above copyright 0020 * notice, this list of conditions and the following disclaimer. 0021 * 2. Redistributions in binary form must reproduce the above copyright 0022 * notice, this list of conditions and the following disclaimer in the 0023 * documentation and/or other materials provided with the distribution. 0024 * 0025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0028 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0029 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0030 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0031 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0032 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0033 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0034 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0035 * POSSIBILITY OF SUCH DAMAGE. 0036 */ 0037 0038 #ifndef _RTEMS_SCORE_STATESIMPL_H 0039 #define _RTEMS_SCORE_STATESIMPL_H 0040 0041 #include <rtems/score/states.h> 0042 #include <rtems/score/basedefs.h> 0043 0044 #ifdef __cplusplus 0045 extern "C" { 0046 #endif 0047 0048 /** 0049 * @addtogroup RTEMSScoreStates 0050 * 0051 * @{ 0052 */ 0053 0054 /* 0055 * The following constants define the individual states which may be 0056 * be used to compose and manipulate a thread's state. More frequently used 0057 * states should use lower value bits to ease the use of immediate values on 0058 * RISC architectures. 0059 */ 0060 0061 /** This macro corresponds to a task being ready. */ 0062 #define STATES_READY 0x00000000 0063 0064 /** This macro corresponds to a task waiting for a mutex. */ 0065 #define STATES_WAITING_FOR_MUTEX 0x00000001 0066 0067 /** This macro corresponds to a task waiting for a semaphore. */ 0068 #define STATES_WAITING_FOR_SEMAPHORE 0x00000002 0069 0070 /** This macro corresponds to a task waiting for an event. */ 0071 #define STATES_WAITING_FOR_EVENT 0x00000004 0072 0073 /** This macro corresponds to a task waiting for a system event. */ 0074 #define STATES_WAITING_FOR_SYSTEM_EVENT 0x00000008 0075 0076 /** This macro corresponds to a task waiting for a message. */ 0077 #define STATES_WAITING_FOR_MESSAGE 0x00000010 0078 0079 /** This macro corresponds to a task waiting for a condition variable. */ 0080 #define STATES_WAITING_FOR_CONDITION_VARIABLE 0x00000020 0081 0082 /** This macro corresponds to a task waiting for a futex. */ 0083 #define STATES_WAITING_FOR_FUTEX 0x00000040 0084 0085 /** This macro corresponds to a task waiting for BSD wakeup. */ 0086 #define STATES_WAITING_FOR_BSD_WAKEUP 0x00000080 0087 0088 /** 0089 * @brief This macro corresponds to a task which is waiting for a relative or 0090 * absolute timeout. 0091 */ 0092 #define STATES_WAITING_FOR_TIME 0x00000100 0093 0094 /** This macro corresponds to a task waiting for a period. */ 0095 #define STATES_WAITING_FOR_PERIOD 0x00000200 0096 0097 /** This macro corresponds to a task waiting for a signal. */ 0098 #define STATES_WAITING_FOR_SIGNAL 0x00000400 0099 0100 /** This macro corresponds to a task waiting for a barrier. */ 0101 #define STATES_WAITING_FOR_BARRIER 0x00000800 0102 0103 /** This macro corresponds to a task waiting for a RWLock. */ 0104 #define STATES_WAITING_FOR_RWLOCK 0x00001000 0105 0106 /** This macro corresponds to a task waiting for a join while exiting. */ 0107 #define STATES_WAITING_FOR_JOIN_AT_EXIT 0x00002000 0108 0109 /** This macro corresponds to a task waiting for a join. */ 0110 #define STATES_WAITING_FOR_JOIN 0x00004000 0111 0112 /** This macro corresponds to a task being suspended. */ 0113 #define STATES_SUSPENDED 0x00008000 0114 0115 /** This macro corresponds to a task waiting for a fixed size segment. */ 0116 #define STATES_WAITING_FOR_SEGMENT 0x00010000 0117 0118 /** This macro corresponds to a task those life is changing. */ 0119 #define STATES_LIFE_IS_CHANGING 0x00020000 0120 0121 /** This macro corresponds to a task being held by the debugger. */ 0122 #define STATES_DEBUGGER 0x08000000 0123 0124 /** This macro corresponds to a task which is in an interruptible 0125 * blocking state. 0126 */ 0127 #define STATES_INTERRUPTIBLE_BY_SIGNAL 0x10000000 0128 0129 /** This macro corresponds to a task waiting for a reply to an MPCI request. */ 0130 #define STATES_WAITING_FOR_RPC_REPLY 0x20000000 0131 0132 /** This macro corresponds to a task being a zombie. */ 0133 #define STATES_ZOMBIE 0x40000000 0134 0135 /** This macro corresponds to a task being created but not yet started. */ 0136 #define STATES_DORMANT 0x80000000 0137 0138 /** This macro corresponds to a task waiting for a local object operation. */ 0139 #define STATES_LOCALLY_BLOCKED ( STATES_WAITING_FOR_SEGMENT | \ 0140 STATES_WAITING_FOR_MESSAGE | \ 0141 STATES_WAITING_FOR_SEMAPHORE | \ 0142 STATES_WAITING_FOR_MUTEX | \ 0143 STATES_WAITING_FOR_CONDITION_VARIABLE | \ 0144 STATES_WAITING_FOR_JOIN | \ 0145 STATES_WAITING_FOR_SIGNAL | \ 0146 STATES_WAITING_FOR_BARRIER | \ 0147 STATES_WAITING_FOR_BSD_WAKEUP | \ 0148 STATES_WAITING_FOR_FUTEX | \ 0149 STATES_WAITING_FOR_RWLOCK ) 0150 0151 /** This macro corresponds to a task waiting which is blocked. */ 0152 #define STATES_BLOCKED ( STATES_LOCALLY_BLOCKED | \ 0153 STATES_WAITING_FOR_TIME | \ 0154 STATES_WAITING_FOR_PERIOD | \ 0155 STATES_WAITING_FOR_EVENT | \ 0156 STATES_WAITING_FOR_RPC_REPLY | \ 0157 STATES_WAITING_FOR_SYSTEM_EVENT | \ 0158 STATES_INTERRUPTIBLE_BY_SIGNAL ) 0159 0160 /** All state bits set to one (provided for _Thread_Start()) */ 0161 #define STATES_ALL_SET 0xffffffff 0162 0163 /** 0164 * @brief Returns the result of setting the states to set to the given state. 0165 * 0166 * This function sets the given @a states_to_set into the @a current_state 0167 * passed in. The result is returned to the user in @a current_state. 0168 * 0169 * @param states_to_set The state bits to set. 0170 * @param current_state The state set to add them to. 0171 * 0172 * @return This method returns the updated states value. 0173 */ 0174 static inline States_Control _States_Set ( 0175 States_Control states_to_set, 0176 States_Control current_state 0177 ) 0178 { 0179 return (current_state | states_to_set); 0180 } 0181 0182 /** 0183 * @brief Clears the states into the passed current state and returns the result. 0184 * 0185 * This function clears the given @a states_to_clear into the @a current_state 0186 * passed in. The result is returned to the user in @a current_state. 0187 * 0188 * @param states_to_clear The state bits to clear. 0189 * @param current_state The state set to remove them from. 0190 * 0191 * @return This method returns the updated states value. 0192 */ 0193 static inline States_Control _States_Clear ( 0194 States_Control states_to_clear, 0195 States_Control current_state 0196 ) 0197 { 0198 return (current_state & ~states_to_clear); 0199 } 0200 0201 /** 0202 * @brief Checks if the state is ready. 0203 * 0204 * This function returns true if the_states indicates that the 0205 * state is READY, and false otherwise. 0206 * 0207 * @param the_states The task state set to test. 0208 * 0209 * @retval true The state is ready. 0210 * @retval false The state is not ready. 0211 */ 0212 static inline bool _States_Is_ready ( 0213 States_Control the_states 0214 ) 0215 { 0216 return (the_states == STATES_READY); 0217 } 0218 0219 /** 0220 * @brief Checks if DORMANT state is set. 0221 * 0222 * This function returns true if the DORMANT state is set in 0223 * @a the_states, and false otherwise. 0224 * 0225 * @param the_states The task state set to test. 0226 * 0227 * @retval true DORMANT state is set in @a the_states. 0228 * @retval false DORMANT state is not set in @a the_states. 0229 */ 0230 static inline bool _States_Is_dormant ( 0231 States_Control the_states 0232 ) 0233 { 0234 return (the_states & STATES_DORMANT); 0235 } 0236 0237 /** 0238 * @brief Checks if SUSPENDED state is set. 0239 * 0240 * This function returns true if the SUSPENDED state is set in 0241 * @a the_states, and false otherwise. 0242 * 0243 * @param the_states The task state set to test. 0244 * 0245 * @retval true SUSPENDED state is set in @a the_states. 0246 * @retval false SUSPENDED state is not set in @a the_states. 0247 */ 0248 static inline bool _States_Is_suspended ( 0249 States_Control the_states 0250 ) 0251 { 0252 return (the_states & STATES_SUSPENDED); 0253 } 0254 0255 /** 0256 * @brief Checks if WAITING_FOR_TIME state is set. 0257 * 0258 * This function returns true if the WAITING_FOR_TIME state is set in 0259 * @a the_states, and false otherwise. 0260 * 0261 * @param the_states The task state set to test. 0262 * 0263 * @retval true WAITING_FOR_TIME state is set in @a the_states. 0264 * @retval false WAITING_FOR_TIME state is not set in @a the_states. 0265 */ 0266 static inline bool _States_Is_waiting_for_rpc_reply ( 0267 States_Control the_states 0268 ) 0269 { 0270 return (the_states & STATES_WAITING_FOR_RPC_REPLY); 0271 } 0272 0273 /** 0274 * @brief Checks if WAITING_FOR_JOIN_AT_EXIT state is set. 0275 * 0276 * This function returns true if the WAITING_FOR_JOIN_AT_EXIT state is set in 0277 * @a the_states, and false otherwise. 0278 * 0279 * @param the_states The task state set to test. 0280 * 0281 * @retval true WAITING_FOR_JOIN_AT_EXIT state is set in @a the_states. 0282 * @retval false WAITING_FOR_JOIN_AT_EXIT state is not set in @a the_states. 0283 */ 0284 static inline bool _States_Is_waiting_for_join_at_exit( 0285 States_Control the_states 0286 ) 0287 { 0288 return ( the_states & STATES_WAITING_FOR_JOIN_AT_EXIT ) != 0; 0289 } 0290 0291 /** 0292 * @brief Checks if the state is set to be interruptible. 0293 * 0294 * This function returns true if the task's state is set in 0295 * way that allows it to be interrupted by a signal. 0296 * 0297 * @param the_states The task state set to test. 0298 * 0299 * @retval true @a the_states is interruptible. 0300 * @retval false @a the_states is not interruptible. 0301 */ 0302 static inline bool _States_Is_interruptible_by_signal ( 0303 States_Control the_states 0304 ) 0305 { 0306 return (the_states & STATES_INTERRUPTIBLE_BY_SIGNAL); 0307 } 0308 0309 /** 0310 * @brief Checks if the state is blocked waiting on a local resource. 0311 * 0312 * This function returns true if one of the states which indicates 0313 * that a task is blocked waiting for a local resource is set in 0314 * the_states, and false otherwise. 0315 * 0316 * @param the_states The task state set to test. 0317 * 0318 * @retval true The state indicates that the task is blocked waiting on a local 0319 * resource. 0320 * @retval false The state indicates that the task is not blocked waiting on a 0321 * local resource. 0322 */ 0323 static inline bool _States_Is_locally_blocked ( 0324 States_Control the_states 0325 ) 0326 { 0327 return (the_states & STATES_LOCALLY_BLOCKED); 0328 } 0329 0330 /** @} */ 0331 0332 #ifdef __cplusplus 0333 } 0334 #endif 0335 0336 #endif 0337 /* end of include file */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |