[20f02c6] | 1 | /** |
---|
[11874561] | 2 | * @file rtems/score/thread.h |
---|
[ac7d5ef0] | 3 | * |
---|
[319cb20] | 4 | * @brief Constants and Structures Related with the Thread Control Block |
---|
| 5 | * |
---|
[ac7d5ef0] | 6 | * This include file contains all constants and structures associated |
---|
| 7 | * with the thread control block. |
---|
[baff4da] | 8 | */ |
---|
| 9 | |
---|
| 10 | /* |
---|
[3203e09] | 11 | * COPYRIGHT (c) 1989-2009. |
---|
[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 |
---|
[dd687d97] | 16 | * http://www.rtems.com/license/LICENSE. |
---|
[ac7d5ef0] | 17 | */ |
---|
| 18 | |
---|
[092f142a] | 19 | #ifndef _RTEMS_SCORE_THREAD_H |
---|
| 20 | #define _RTEMS_SCORE_THREAD_H |
---|
[ac7d5ef0] | 21 | |
---|
[baff4da] | 22 | /** |
---|
| 23 | * @defgroup ScoreThread Thread Handler |
---|
| 24 | * |
---|
[d8cd045c] | 25 | * @ingroup Score |
---|
| 26 | * |
---|
[6a07436] | 27 | * This handler encapsulates functionality related to the management of |
---|
| 28 | * threads. This includes the creation, deletion, and scheduling of threads. |
---|
[11e8bc5] | 29 | * |
---|
| 30 | * The following variables are maintained as part of the per cpu data |
---|
| 31 | * structure. |
---|
| 32 | * |
---|
| 33 | * + Idle thread pointer |
---|
| 34 | * + Executing thread pointer |
---|
| 35 | * + Heir thread pointer |
---|
[baff4da] | 36 | */ |
---|
| 37 | /**@{*/ |
---|
| 38 | |
---|
[1ada6163] | 39 | #if defined(RTEMS_POSIX_API) |
---|
[442eac69] | 40 | #define RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE |
---|
| 41 | #endif |
---|
| 42 | |
---|
[fdc70e2] | 43 | /* |
---|
| 44 | * With the addition of the Constant Block Scheduler (CBS), |
---|
| 45 | * this feature is needed even when POSIX is disabled. |
---|
| 46 | */ |
---|
| 47 | #define RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT |
---|
[442eac69] | 48 | |
---|
[bacf79e] | 49 | #if defined(RTEMS_POSIX_API) |
---|
| 50 | #define RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API |
---|
| 51 | #endif |
---|
[442eac69] | 52 | |
---|
[f78831f1] | 53 | /* |
---|
| 54 | * Deferred floating point context switches are not currently |
---|
| 55 | * supported when in SMP configuration. |
---|
| 56 | */ |
---|
| 57 | #if defined(RTEMS_SMP) |
---|
| 58 | #undef CPU_USE_DEFERRED_FP_SWITCH |
---|
| 59 | #define CPU_USE_DEFERRED_FP_SWITCH FALSE |
---|
| 60 | #endif |
---|
| 61 | |
---|
[ac7d5ef0] | 62 | #ifdef __cplusplus |
---|
| 63 | extern "C" { |
---|
| 64 | #endif |
---|
| 65 | |
---|
[11e8bc5] | 66 | #include <rtems/score/percpu.h> |
---|
[5e9b32b] | 67 | #include <rtems/score/context.h> |
---|
| 68 | #include <rtems/score/cpu.h> |
---|
[97e2729d] | 69 | #if defined(RTEMS_MULTIPROCESSING) |
---|
[5e9b32b] | 70 | #include <rtems/score/mppkt.h> |
---|
[97e2729d] | 71 | #endif |
---|
[5e9b32b] | 72 | #include <rtems/score/object.h> |
---|
| 73 | #include <rtems/score/priority.h> |
---|
[0faa9dad] | 74 | #include <rtems/score/scheduler.h> |
---|
[5e9b32b] | 75 | #include <rtems/score/stack.h> |
---|
| 76 | #include <rtems/score/states.h> |
---|
| 77 | #include <rtems/score/tod.h> |
---|
| 78 | #include <rtems/score/tqdata.h> |
---|
| 79 | #include <rtems/score/watchdog.h> |
---|
[ac7d5ef0] | 80 | |
---|
[196fe59] | 81 | /* |
---|
| 82 | * The user can define this at configure time and go back to ticks |
---|
| 83 | * resolution. |
---|
| 84 | */ |
---|
| 85 | #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ |
---|
| 86 | #include <rtems/score/timestamp.h> |
---|
| 87 | |
---|
| 88 | typedef Timestamp_Control Thread_CPU_usage_t; |
---|
| 89 | #else |
---|
| 90 | typedef uint32_t Thread_CPU_usage_t; |
---|
| 91 | #endif |
---|
| 92 | |
---|
[baff4da] | 93 | /** |
---|
[3a4ae6c] | 94 | * The following defines the "return type" of a thread. |
---|
[260b0c2] | 95 | * |
---|
[baff4da] | 96 | * @note This cannot always be right. Some APIs have void |
---|
[a0ed4ed] | 97 | * tasks/threads, others return pointers, others may |
---|
[260b0c2] | 98 | * return a numeric value. Hopefully a pointer is |
---|
[d6154c7] | 99 | * always at least as big as an uint32_t . :) |
---|
[ac7d5ef0] | 100 | */ |
---|
[260b0c2] | 101 | typedef void *Thread; |
---|
[ac7d5ef0] | 102 | |
---|
[3b14b7ad] | 103 | /** |
---|
| 104 | * @brief Type of the numeric argument of a thread entry function with at |
---|
[20f02c6] | 105 | * least one numeric argument. |
---|
[3b14b7ad] | 106 | * |
---|
| 107 | * This numeric argument type designates an unsigned integer type with the |
---|
| 108 | * property that any valid pointer to void can be converted to this type and |
---|
| 109 | * then converted back to a pointer to void. The result will compare equal to |
---|
| 110 | * the original pointer. |
---|
| 111 | */ |
---|
| 112 | typedef uintptr_t Thread_Entry_numeric_type; |
---|
| 113 | |
---|
[baff4da] | 114 | /** |
---|
[3a4ae6c] | 115 | * The following defines the ways in which the entry point for a |
---|
| 116 | * thread can be invoked. Basically, it can be passed any |
---|
[d6154c7] | 117 | * combination/permutation of a pointer and an uint32_t value. |
---|
[3a4ae6c] | 118 | * |
---|
[baff4da] | 119 | * @note For now, we are ignoring the return type. |
---|
[ac7d5ef0] | 120 | */ |
---|
[3a4ae6c] | 121 | typedef enum { |
---|
| 122 | THREAD_START_NUMERIC, |
---|
| 123 | THREAD_START_POINTER, |
---|
[46a67b19] | 124 | #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API) |
---|
| 125 | THREAD_START_BOTH_POINTER_FIRST, |
---|
| 126 | THREAD_START_BOTH_NUMERIC_FIRST |
---|
| 127 | #endif |
---|
[3a4ae6c] | 128 | } Thread_Start_types; |
---|
[ac7d5ef0] | 129 | |
---|
[6a07436] | 130 | /** This type corresponds to a very simple style thread entry point. */ |
---|
[5742e5e] | 131 | typedef Thread ( *Thread_Entry )( void ); /* basic type */ |
---|
[0d051533] | 132 | |
---|
[6a07436] | 133 | /** This type corresponds to a thread entry point which takes a single |
---|
| 134 | * unsigned thirty-two bit integer as an argument. |
---|
| 135 | */ |
---|
[3b14b7ad] | 136 | typedef Thread ( *Thread_Entry_numeric )( Thread_Entry_numeric_type ); |
---|
[baff4da] | 137 | |
---|
[6a07436] | 138 | /** This type corresponds to a thread entry point which takes a single |
---|
| 139 | * untyped pointer as an argument. |
---|
[baff4da] | 140 | */ |
---|
[0d051533] | 141 | typedef Thread ( *Thread_Entry_pointer )( void * ); |
---|
[baff4da] | 142 | |
---|
[6a07436] | 143 | /** This type corresponds to a thread entry point which takes a single |
---|
| 144 | * untyped pointer and an unsigned thirty-two bit integer as arguments. |
---|
[baff4da] | 145 | */ |
---|
[3b14b7ad] | 146 | typedef Thread ( *Thread_Entry_both_pointer_first )( void *, Thread_Entry_numeric_type ); |
---|
[baff4da] | 147 | |
---|
[6a07436] | 148 | /** This type corresponds to a thread entry point which takes a single |
---|
| 149 | * unsigned thirty-two bit integer and an untyped pointer and an |
---|
| 150 | * as arguments. |
---|
[baff4da] | 151 | */ |
---|
[3b14b7ad] | 152 | typedef Thread ( *Thread_Entry_both_numeric_first )( Thread_Entry_numeric_type, void * ); |
---|
[ac7d5ef0] | 153 | |
---|
[baff4da] | 154 | /** |
---|
[2f200c7] | 155 | * The following lists the algorithms used to manage the thread cpu budget. |
---|
| 156 | * |
---|
| 157 | * Reset Timeslice: At each context switch, reset the time quantum. |
---|
| 158 | * Exhaust Timeslice: Only reset the quantum once it is consumed. |
---|
| 159 | * Callout: Execute routine when budget is consumed. |
---|
| 160 | */ |
---|
| 161 | typedef enum { |
---|
| 162 | THREAD_CPU_BUDGET_ALGORITHM_NONE, |
---|
| 163 | THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE, |
---|
[442eac69] | 164 | #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE) |
---|
| 165 | THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE, |
---|
| 166 | #endif |
---|
| 167 | #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT) |
---|
| 168 | THREAD_CPU_BUDGET_ALGORITHM_CALLOUT |
---|
| 169 | #endif |
---|
[2f200c7] | 170 | } Thread_CPU_budget_algorithms; |
---|
| 171 | |
---|
[6a07436] | 172 | /** This defines thes the entry point for the thread specific timeslice |
---|
| 173 | * budget management algorithm. |
---|
[baff4da] | 174 | */ |
---|
[2f200c7] | 175 | typedef void (*Thread_CPU_budget_algorithm_callout )( Thread_Control * ); |
---|
| 176 | |
---|
[4b72da4] | 177 | /** |
---|
[319cb20] | 178 | * @brief Forward reference to the per task variable structure.. |
---|
[baff4da] | 179 | * |
---|
| 180 | * Forward reference to the per task variable structure. |
---|
[aad726e] | 181 | */ |
---|
| 182 | struct rtems_task_variable_tt; |
---|
| 183 | |
---|
[4b72da4] | 184 | /** |
---|
[319cb20] | 185 | * @brief Internal structure used to manager per task variables. |
---|
[baff4da] | 186 | * |
---|
| 187 | * This is the internal structure used to manager per Task Variables. |
---|
| 188 | */ |
---|
[6a07436] | 189 | typedef struct { |
---|
[baff4da] | 190 | /** This field points to the next per task variable for this task. */ |
---|
[aad726e] | 191 | struct rtems_task_variable_tt *next; |
---|
[baff4da] | 192 | /** This field points to the physical memory location of this per |
---|
| 193 | * task variable. |
---|
| 194 | */ |
---|
[c941a98] | 195 | void **ptr; |
---|
[baff4da] | 196 | /** This field is to the global value for this per task variable. */ |
---|
[df49c60] | 197 | void *gval; |
---|
[baff4da] | 198 | /** This field is to this thread's value for this per task variable. */ |
---|
[df49c60] | 199 | void *tval; |
---|
[baff4da] | 200 | /** This field points to the destructor for this per task variable. */ |
---|
[c941a98] | 201 | void (*dtor)(void *); |
---|
[6a07436] | 202 | } rtems_task_variable_t; |
---|
[aad726e] | 203 | |
---|
[baff4da] | 204 | /** |
---|
[ac7d5ef0] | 205 | * The following structure contains the information which defines |
---|
| 206 | * the starting state of a thread. |
---|
| 207 | */ |
---|
| 208 | typedef struct { |
---|
[6a07436] | 209 | /** This field is the starting address for the thread. */ |
---|
[3b14b7ad] | 210 | Thread_Entry entry_point; |
---|
[6cd8bbe] | 211 | /** This field indicates the how task is invoked. */ |
---|
[3b14b7ad] | 212 | Thread_Start_types prototype; |
---|
[6a07436] | 213 | /** This field is the pointer argument passed at thread start. */ |
---|
[3b14b7ad] | 214 | void *pointer_argument; |
---|
[6a07436] | 215 | /** This field is the numeric argument passed at thread start. */ |
---|
[3b14b7ad] | 216 | Thread_Entry_numeric_type numeric_argument; |
---|
[6a07436] | 217 | /*-------------- initial execution modes ----------------- */ |
---|
| 218 | /** This field indicates whether the thread was preemptible when |
---|
| 219 | * it started. |
---|
| 220 | */ |
---|
[484a769] | 221 | bool is_preemptible; |
---|
[6a07436] | 222 | /** This field indicates the CPU budget algorith. */ |
---|
[3b14b7ad] | 223 | Thread_CPU_budget_algorithms budget_algorithm; |
---|
[6a07436] | 224 | /** This field is the routine to invoke when the CPU allotment is |
---|
| 225 | * consumed. |
---|
| 226 | */ |
---|
[3b14b7ad] | 227 | Thread_CPU_budget_algorithm_callout budget_callout; |
---|
[6a07436] | 228 | /** This field is the initial ISR disable level of this thread. */ |
---|
[3b14b7ad] | 229 | uint32_t isr_level; |
---|
[6a07436] | 230 | /** This field is the initial priority. */ |
---|
[3b14b7ad] | 231 | Priority_Control initial_priority; |
---|
[bacf79e] | 232 | #if defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API) |
---|
| 233 | /** This field indicates whether the SuperCore allocated the stack. */ |
---|
| 234 | bool core_allocated_stack; |
---|
| 235 | #endif |
---|
[6a07436] | 236 | /** This field is the stack information. */ |
---|
[3b14b7ad] | 237 | Stack_Control Initial_stack; |
---|
[bacf79e] | 238 | #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) |
---|
| 239 | /** This field is the initial FP context area address. */ |
---|
| 240 | Context_Control_fp *fp_context; |
---|
| 241 | #endif |
---|
[6a07436] | 242 | /** This field is the initial stack area address. */ |
---|
[3b14b7ad] | 243 | void *stack; |
---|
| 244 | } Thread_Start_information; |
---|
[ac7d5ef0] | 245 | |
---|
[baff4da] | 246 | /** |
---|
[ac7d5ef0] | 247 | * The following structure contains the information necessary to manage |
---|
| 248 | * a thread which it is waiting for a resource. |
---|
| 249 | */ |
---|
[3a4ae6c] | 250 | #define THREAD_STATUS_PROXY_BLOCKING 0x1111111 |
---|
| 251 | |
---|
[f773c012] | 252 | /** |
---|
| 253 | * @brief Union type to hold a pointer to an immutable or a mutable object. |
---|
| 254 | * |
---|
| 255 | * The main purpose is to enable passing of pointers to read-only send buffers |
---|
| 256 | * in the message passing subsystem. This approach is somewhat fragile since |
---|
| 257 | * it prevents the compiler to check if the operations on objects are valid |
---|
| 258 | * with respect to the constant qualifier. An alternative would be to add a |
---|
| 259 | * third pointer argument for immutable objects, but this would increase the |
---|
| 260 | * structure size. |
---|
| 261 | */ |
---|
| 262 | typedef union { |
---|
| 263 | void *mutable_object; |
---|
| 264 | const void *immutable_object; |
---|
| 265 | } Thread_Wait_information_Object_argument_type; |
---|
| 266 | |
---|
[4b72da4] | 267 | /** |
---|
[319cb20] | 268 | * @brief Information required to manage a thread while it is blocked. |
---|
[baff4da] | 269 | * |
---|
| 270 | * This contains the information required to manage a thread while it is |
---|
| 271 | * blocked and to return information to it. |
---|
| 272 | */ |
---|
[ac7d5ef0] | 273 | typedef struct { |
---|
[baff4da] | 274 | /** This field is the Id of the object this thread is waiting upon. */ |
---|
| 275 | Objects_Id id; |
---|
| 276 | /** This field is used to return an integer while when blocked. */ |
---|
| 277 | uint32_t count; |
---|
[f773c012] | 278 | /** This field is for a pointer to a user return argument. */ |
---|
[baff4da] | 279 | void *return_argument; |
---|
[f773c012] | 280 | /** This field is for a pointer to a second user return argument. */ |
---|
| 281 | Thread_Wait_information_Object_argument_type |
---|
| 282 | return_argument_second; |
---|
[baff4da] | 283 | /** This field contains any options in effect on this blocking operation. */ |
---|
[d6154c7] | 284 | uint32_t option; |
---|
[baff4da] | 285 | /** This field will contain the return status from a blocking operation. |
---|
[20f02c6] | 286 | * |
---|
[baff4da] | 287 | * @note The following assumes that all API return codes can be |
---|
| 288 | * treated as an uint32_t. |
---|
[3a4ae6c] | 289 | */ |
---|
[baff4da] | 290 | uint32_t return_code; |
---|
[3a4ae6c] | 291 | |
---|
[20f02c6] | 292 | /** This field is the chain header for the second through Nth tasks |
---|
[baff4da] | 293 | * of the same priority blocked waiting on the same object. |
---|
| 294 | */ |
---|
| 295 | Chain_Control Block2n; |
---|
| 296 | /** This field points to the thread queue on which this thread is blocked. */ |
---|
| 297 | Thread_queue_Control *queue; |
---|
[ac7d5ef0] | 298 | } Thread_Wait_information; |
---|
| 299 | |
---|
[baff4da] | 300 | /** |
---|
[ac7d5ef0] | 301 | * The following defines the control block used to manage |
---|
| 302 | * each thread proxy. |
---|
| 303 | * |
---|
[baff4da] | 304 | * @note It is critical that proxies and threads have identical |
---|
[ac7d5ef0] | 305 | * memory images for the shared part. |
---|
| 306 | */ |
---|
| 307 | typedef struct { |
---|
[6a07436] | 308 | /** This field is the object management structure for each proxy. */ |
---|
[ac7d5ef0] | 309 | Objects_Control Object; |
---|
[6a07436] | 310 | /** This field is the current execution state of this proxy. */ |
---|
[ac7d5ef0] | 311 | States_Control current_state; |
---|
[6a07436] | 312 | /** This field is the current priority state of this proxy. */ |
---|
[7f6a24ab] | 313 | Priority_Control current_priority; |
---|
[6a07436] | 314 | /** This field is the base priority of this proxy. */ |
---|
[7f6a24ab] | 315 | Priority_Control real_priority; |
---|
[6a07436] | 316 | /** This field is the number of mutexes currently held by this proxy. */ |
---|
[d6154c7] | 317 | uint32_t resource_count; |
---|
[fd84982] | 318 | |
---|
[6a07436] | 319 | /** This field is the blocking information for this proxy. */ |
---|
[ac7d5ef0] | 320 | Thread_Wait_information Wait; |
---|
[6a07436] | 321 | /** This field is the Watchdog used to manage proxy delays and timeouts. */ |
---|
[ac7d5ef0] | 322 | Watchdog_Control Timer; |
---|
[97e2729d] | 323 | #if defined(RTEMS_MULTIPROCESSING) |
---|
[6a07436] | 324 | /** This field is the received response packet in an MP system. */ |
---|
[3a4ae6c] | 325 | MP_packet_Prefix *receive_packet; |
---|
[97e2729d] | 326 | #endif |
---|
[ac7d5ef0] | 327 | /****************** end of common block ********************/ |
---|
[6a07436] | 328 | /** This field is used to manage the set of proxies in the system. */ |
---|
[ac7d5ef0] | 329 | Chain_Node Active; |
---|
| 330 | } Thread_Proxy_control; |
---|
| 331 | |
---|
[baff4da] | 332 | /** |
---|
[ac7d5ef0] | 333 | * The following record defines the control block used |
---|
| 334 | * to manage each thread. |
---|
| 335 | * |
---|
[baff4da] | 336 | * @note It is critical that proxies and threads have identical |
---|
[ac7d5ef0] | 337 | * memory images for the shared part. |
---|
| 338 | */ |
---|
[3a4ae6c] | 339 | typedef enum { |
---|
[6a07436] | 340 | /** This value is for the Classic RTEMS API. */ |
---|
[5e9b32b] | 341 | THREAD_API_RTEMS, |
---|
[6a07436] | 342 | /** This value is for the POSIX API. */ |
---|
[f0caa05] | 343 | THREAD_API_POSIX |
---|
[3a4ae6c] | 344 | } Thread_APIs; |
---|
[7f6a24ab] | 345 | |
---|
[6a07436] | 346 | /** This macro defines the first API which has threads. */ |
---|
[3a4ae6c] | 347 | #define THREAD_API_FIRST THREAD_API_RTEMS |
---|
[baff4da] | 348 | |
---|
[6a07436] | 349 | /** This macro defines the last API which has threads. */ |
---|
[f0caa05] | 350 | #define THREAD_API_LAST THREAD_API_POSIX |
---|
[7f6a24ab] | 351 | |
---|
[baff4da] | 352 | /** |
---|
[6a07436] | 353 | * This structure defines the Thread Control Block (TCB). |
---|
[baff4da] | 354 | */ |
---|
[2f200c7] | 355 | struct Thread_Control_struct { |
---|
[6a07436] | 356 | /** This field is the object management structure for each thread. */ |
---|
| 357 | Objects_Control Object; |
---|
| 358 | /** This field is the current execution state of this thread. */ |
---|
| 359 | States_Control current_state; |
---|
| 360 | /** This field is the current priority state of this thread. */ |
---|
| 361 | Priority_Control current_priority; |
---|
| 362 | /** This field is the base priority of this thread. */ |
---|
| 363 | Priority_Control real_priority; |
---|
| 364 | /** This field is the number of mutexes currently held by this thread. */ |
---|
| 365 | uint32_t resource_count; |
---|
| 366 | /** This field is the blocking information for this thread. */ |
---|
| 367 | Thread_Wait_information Wait; |
---|
| 368 | /** This field is the Watchdog used to manage thread delays and timeouts. */ |
---|
| 369 | Watchdog_Control Timer; |
---|
[97e2729d] | 370 | #if defined(RTEMS_MULTIPROCESSING) |
---|
[6a07436] | 371 | /** This field is the received response packet in an MP system. */ |
---|
| 372 | MP_packet_Prefix *receive_packet; |
---|
[fd84982] | 373 | #endif |
---|
[66a9239a] | 374 | #ifdef __RTEMS_STRICT_ORDER_MUTEX__ |
---|
[931dd97] | 375 | /** This field is the head of queue of priority inheritance mutex |
---|
| 376 | * held by the thread. |
---|
| 377 | */ |
---|
[fd84982] | 378 | Chain_Control lock_mutex; |
---|
[97e2729d] | 379 | #endif |
---|
[6a07436] | 380 | /*================= end of common block =================*/ |
---|
[931dd97] | 381 | #if defined(RTEMS_MULTIPROCESSING) |
---|
[6a07436] | 382 | /** This field is true if the thread is offered globally */ |
---|
[484a769] | 383 | bool is_global; |
---|
[931dd97] | 384 | #endif |
---|
[6a07436] | 385 | /** This field is true if the thread is preemptible. */ |
---|
[484a769] | 386 | bool is_preemptible; |
---|
[81b329a] | 387 | #if __RTEMS_ADA__ |
---|
[6a07436] | 388 | /** This field is the GNAT self context pointer. */ |
---|
[847375f] | 389 | void *rtems_ada_self; |
---|
[81b329a] | 390 | #endif |
---|
[6a07436] | 391 | /** This field is the length of the time quantum that this thread is |
---|
| 392 | * allowed to consume. The algorithm used to manage limits on CPU usage |
---|
| 393 | * is specified by budget_algorithm. |
---|
| 394 | */ |
---|
[d6154c7] | 395 | uint32_t cpu_time_budget; |
---|
[6a07436] | 396 | /** This field is the algorithm used to manage this thread's time |
---|
| 397 | * quantum. The algorithm may be specified as none which case, |
---|
| 398 | * no limit is in place. |
---|
| 399 | */ |
---|
[2f200c7] | 400 | Thread_CPU_budget_algorithms budget_algorithm; |
---|
[6a07436] | 401 | /** This field is the method invoked with the budgeted time is consumed. */ |
---|
[2f200c7] | 402 | Thread_CPU_budget_algorithm_callout budget_callout; |
---|
[c3330a8] | 403 | /** This field is the amount of CPU time consumed by this thread |
---|
[6a07436] | 404 | * since it was created. |
---|
| 405 | */ |
---|
[9dc2c8d] | 406 | Thread_CPU_usage_t cpu_time_used; |
---|
[108c4b0] | 407 | |
---|
| 408 | /** This pointer holds per-thread data for the scheduler and ready queue. */ |
---|
| 409 | void *scheduler_info; |
---|
| 410 | |
---|
[6a07436] | 411 | /** This field contains information about the starting state of |
---|
| 412 | * this thread. |
---|
| 413 | */ |
---|
[2f200c7] | 414 | Thread_Start_information Start; |
---|
[6a07436] | 415 | /** This field contains the context of this thread. */ |
---|
[2f200c7] | 416 | Context_Control Registers; |
---|
[499d443] | 417 | #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) |
---|
[6a07436] | 418 | /** This field points to the floating point context for this thread. |
---|
| 419 | * If NULL, the thread is integer only. |
---|
| 420 | */ |
---|
[3c86f88] | 421 | Context_Control_fp *fp_context; |
---|
[17508d02] | 422 | #endif |
---|
[6a07436] | 423 | /** This field points to the newlib reentrancy structure for this thread. */ |
---|
[d36b3152] | 424 | struct _reent *libc_reent; |
---|
[6a07436] | 425 | /** This array contains the API extension area pointers. */ |
---|
[2f200c7] | 426 | void *API_Extensions[ THREAD_API_LAST + 1 ]; |
---|
[6a07436] | 427 | /** This field points to the user extension pointers. */ |
---|
[2f200c7] | 428 | void **extensions; |
---|
[6a07436] | 429 | /** This field points to the set of per task variables. */ |
---|
[aad726e] | 430 | rtems_task_variable_t *task_variables; |
---|
[2f200c7] | 431 | }; |
---|
[ac7d5ef0] | 432 | |
---|
[baff4da] | 433 | /** |
---|
[847375f] | 434 | * Self for the GNU Ada Run-Time |
---|
| 435 | */ |
---|
| 436 | SCORE_EXTERN void *rtems_ada_self; |
---|
[05279b84] | 437 | |
---|
[baff4da] | 438 | /** |
---|
[adf98bd] | 439 | * The following defines the information control block used to |
---|
| 440 | * manage this class of objects. |
---|
| 441 | */ |
---|
[c627b2a3] | 442 | SCORE_EXTERN Objects_Information _Thread_Internal_information; |
---|
[05279b84] | 443 | |
---|
[baff4da] | 444 | /** |
---|
[3a4ae6c] | 445 | * The following context area contains the context of the "thread" |
---|
[a0ed4ed] | 446 | * which invoked the start multitasking routine. This context is |
---|
[3a4ae6c] | 447 | * restored as the last action of the stop multitasking routine. Thus |
---|
| 448 | * control of the processor can be returned to the environment |
---|
| 449 | * which initiated the system. |
---|
[ac7d5ef0] | 450 | */ |
---|
[c627b2a3] | 451 | SCORE_EXTERN Context_Control _Thread_BSP_context; |
---|
[05279b84] | 452 | |
---|
[baff4da] | 453 | /** |
---|
[3a4ae6c] | 454 | * The following holds how many user extensions are in the system. This |
---|
| 455 | * is used to determine how many user extension data areas to allocate |
---|
| 456 | * per thread. |
---|
| 457 | */ |
---|
[d6154c7] | 458 | SCORE_EXTERN uint32_t _Thread_Maximum_extensions; |
---|
[3a4ae6c] | 459 | |
---|
[baff4da] | 460 | /** |
---|
[7aa4671] | 461 | * The following is used to manage the length of a timeslice quantum. |
---|
[ac7d5ef0] | 462 | */ |
---|
[d6154c7] | 463 | SCORE_EXTERN uint32_t _Thread_Ticks_per_timeslice; |
---|
[ac7d5ef0] | 464 | |
---|
[baff4da] | 465 | /** |
---|
[ac7d5ef0] | 466 | * The following points to the thread whose floating point |
---|
| 467 | * context is currently loaded. |
---|
| 468 | */ |
---|
[499d443] | 469 | #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) |
---|
[c627b2a3] | 470 | SCORE_EXTERN Thread_Control *_Thread_Allocated_fp; |
---|
[17508d02] | 471 | #endif |
---|
[ac7d5ef0] | 472 | |
---|
[baff4da] | 473 | /** |
---|
[0df8293e] | 474 | * The C library re-enter-rant global pointer. Some C library implementations |
---|
| 475 | * such as newlib have a single global pointer that changed during a context |
---|
| 476 | * switch. The pointer points to that global pointer. The Thread control block |
---|
| 477 | * holds a pointer to the task specific data. |
---|
| 478 | */ |
---|
[d36b3152] | 479 | SCORE_EXTERN struct _reent **_Thread_libc_reent; |
---|
[baff4da] | 480 | /** |
---|
[319cb20] | 481 | * @brief Initialize thread handler. |
---|
[e0f91da] | 482 | * |
---|
[ac7d5ef0] | 483 | * This routine performs the initialization necessary for this handler. |
---|
| 484 | */ |
---|
[790b50b] | 485 | void _Thread_Handler_initialization(void); |
---|
[ac7d5ef0] | 486 | |
---|
[baff4da] | 487 | /** |
---|
[319cb20] | 488 | * @brief Create idle thread. |
---|
[e655f7e] | 489 | * |
---|
[adf98bd] | 490 | * This routine creates the idle thread. |
---|
| 491 | * |
---|
[baff4da] | 492 | * @warning No thread should be created before this one. |
---|
[adf98bd] | 493 | */ |
---|
[790b50b] | 494 | void _Thread_Create_idle(void); |
---|
[adf98bd] | 495 | |
---|
[baff4da] | 496 | /** |
---|
[319cb20] | 497 | * @brief Start thread multitasking. |
---|
[e655f7e] | 498 | * |
---|
[ac7d5ef0] | 499 | * This routine initiates multitasking. It is invoked only as |
---|
| 500 | * part of initialization and its invocation is the last act of |
---|
[3a4ae6c] | 501 | * the non-multitasking part of the system initialization. |
---|
[e0f91da] | 502 | * |
---|
| 503 | * |
---|
[e655f7e] | 504 | * - INTERRUPT LATENCY: |
---|
| 505 | * + ready chain |
---|
| 506 | * + select heir |
---|
[ac7d5ef0] | 507 | */ |
---|
[b2b52cbc] | 508 | void _Thread_Start_multitasking( void ); |
---|
[ac7d5ef0] | 509 | |
---|
[baff4da] | 510 | /** |
---|
[319cb20] | 511 | * @brief Allocate the requested stack space for the thread. |
---|
[bf54252] | 512 | * |
---|
[1178b8c] | 513 | * Allocate the requested stack space for the thread. |
---|
[bf54252] | 514 | * Set the Start.stack field to the address of the stack. |
---|
| 515 | * |
---|
| 516 | * @param[in] the_thread is the thread where the stack space is requested |
---|
[e0f91da] | 517 | * |
---|
[bf54252] | 518 | * @retval actual size allocated after any adjustment |
---|
| 519 | * @retval zero if the allocation failed |
---|
[1178b8c] | 520 | */ |
---|
[728a0bd3] | 521 | size_t _Thread_Stack_Allocate( |
---|
[1178b8c] | 522 | Thread_Control *the_thread, |
---|
[728a0bd3] | 523 | size_t stack_size |
---|
[1178b8c] | 524 | ); |
---|
| 525 | |
---|
[baff4da] | 526 | /** |
---|
[319cb20] | 527 | * @brief Deallocate thread stack. |
---|
[e0f91da] | 528 | * |
---|
[1178b8c] | 529 | * Deallocate the Thread's stack. |
---|
| 530 | */ |
---|
| 531 | void _Thread_Stack_Free( |
---|
| 532 | Thread_Control *the_thread |
---|
| 533 | ); |
---|
| 534 | |
---|
[baff4da] | 535 | /** |
---|
[319cb20] | 536 | * @brief Initialize thread. |
---|
| 537 | * |
---|
[f6d0821] | 538 | * This routine initializes the specified the thread. It allocates |
---|
| 539 | * all memory associated with this thread. It completes by adding |
---|
| 540 | * the thread to the local object table so operations on this |
---|
| 541 | * thread id are allowed. |
---|
[2f200c7] | 542 | * |
---|
[baff4da] | 543 | * @note If stack_area is NULL, it is allocated from the workspace. |
---|
[2f200c7] | 544 | * |
---|
[baff4da] | 545 | * @note If the stack is allocated from the workspace, then it is |
---|
| 546 | * guaranteed to be of at least minimum size. |
---|
[7f6a24ab] | 547 | */ |
---|
[484a769] | 548 | bool _Thread_Initialize( |
---|
[2f200c7] | 549 | Objects_Information *information, |
---|
| 550 | Thread_Control *the_thread, |
---|
| 551 | void *stack_area, |
---|
[728a0bd3] | 552 | size_t stack_size, |
---|
[484a769] | 553 | bool is_fp, |
---|
[2f200c7] | 554 | Priority_Control priority, |
---|
[484a769] | 555 | bool is_preemptible, |
---|
[2f200c7] | 556 | Thread_CPU_budget_algorithms budget_algorithm, |
---|
| 557 | Thread_CPU_budget_algorithm_callout budget_callout, |
---|
[d6154c7] | 558 | uint32_t isr_level, |
---|
[2f200c7] | 559 | Objects_Name name |
---|
[7f6a24ab] | 560 | ); |
---|
| 561 | |
---|
[baff4da] | 562 | /** |
---|
[319cb20] | 563 | * @brief Initializes thread and executes it. |
---|
[f839bf5a] | 564 | * |
---|
[f6d0821] | 565 | * This routine initializes the executable information for a thread |
---|
| 566 | * and makes it ready to execute. After this routine executes, the |
---|
| 567 | * thread competes with all other threads for CPU time. |
---|
[f839bf5a] | 568 | * |
---|
| 569 | * @param the_thread is the thread to be initialized |
---|
[319cb20] | 570 | * @param the_prototype |
---|
[f839bf5a] | 571 | * @param entry_point |
---|
| 572 | * @param pointer_argument |
---|
| 573 | * @param numeric_argument |
---|
[1ccb64e1] | 574 | * @param[in/out] processor The processor if used to start an idle thread |
---|
| 575 | * during system initialization. Must be set to @c NULL to start a normal |
---|
| 576 | * thread. |
---|
[7f6a24ab] | 577 | */ |
---|
[484a769] | 578 | bool _Thread_Start( |
---|
[3b14b7ad] | 579 | Thread_Control *the_thread, |
---|
| 580 | Thread_Start_types the_prototype, |
---|
| 581 | void *entry_point, |
---|
| 582 | void *pointer_argument, |
---|
[1ccb64e1] | 583 | Thread_Entry_numeric_type numeric_argument, |
---|
| 584 | Per_CPU_Control *processor |
---|
[7f6a24ab] | 585 | ); |
---|
| 586 | |
---|
[baff4da] | 587 | /** |
---|
[319cb20] | 588 | * @brief Restarts the specified thread. |
---|
| 589 | * |
---|
[f6d0821] | 590 | * This support routine restarts the specified task in a way that the |
---|
| 591 | * next time this thread executes, it will begin execution at its |
---|
| 592 | * original starting point. |
---|
[baff4da] | 593 | * |
---|
| 594 | * TODO: multiple task arg profiles |
---|
[7f6a24ab] | 595 | */ |
---|
[484a769] | 596 | bool _Thread_Restart( |
---|
[3b14b7ad] | 597 | Thread_Control *the_thread, |
---|
| 598 | void *pointer_argument, |
---|
| 599 | Thread_Entry_numeric_type numeric_argument |
---|
[7f6a24ab] | 600 | ); |
---|
| 601 | |
---|
[baff4da] | 602 | /** |
---|
[319cb20] | 603 | * @brief Resets a thread to its initial state. |
---|
[bf54252] | 604 | * |
---|
[f6d0821] | 605 | * This routine resets a thread to its initial state but does |
---|
[bf54252] | 606 | * not restart it. Some APIs do this in separate |
---|
| 607 | * operations and this division helps support this. |
---|
| 608 | * |
---|
| 609 | * @param[in] the_thread is the thread to resets |
---|
| 610 | * @param[in] pointer_argument |
---|
| 611 | * @param[in] numeric_argument |
---|
[f6d0821] | 612 | */ |
---|
| 613 | void _Thread_Reset( |
---|
[3b14b7ad] | 614 | Thread_Control *the_thread, |
---|
| 615 | void *pointer_argument, |
---|
| 616 | Thread_Entry_numeric_type numeric_argument |
---|
[f6d0821] | 617 | ); |
---|
| 618 | |
---|
[baff4da] | 619 | /** |
---|
[319cb20] | 620 | * @brief Frees all memory associated with the specified thread. |
---|
[f2f63d1] | 621 | * |
---|
[f6d0821] | 622 | * This routine frees all memory associated with the specified |
---|
| 623 | * thread and removes it from the local object table so no further |
---|
| 624 | * operations on this thread are allowed. |
---|
[7f6a24ab] | 625 | */ |
---|
| 626 | void _Thread_Close( |
---|
| 627 | Objects_Information *information, |
---|
| 628 | Thread_Control *the_thread |
---|
| 629 | ); |
---|
| 630 | |
---|
[baff4da] | 631 | /** |
---|
[319cb20] | 632 | * @brief Removes any set states for @a the_thread. |
---|
[f2f63d1] | 633 | * |
---|
[d4d7899] | 634 | * This routine removes any set states for @a the_thread. It performs |
---|
[ac7d5ef0] | 635 | * any necessary scheduling operations including the selection of |
---|
| 636 | * a new heir thread. |
---|
[e0f91da] | 637 | * |
---|
[f2f63d1] | 638 | * - INTERRUPT LATENCY: |
---|
| 639 | * + ready chain |
---|
| 640 | * + select heir |
---|
[ac7d5ef0] | 641 | */ |
---|
| 642 | void _Thread_Ready( |
---|
| 643 | Thread_Control *the_thread |
---|
| 644 | ); |
---|
| 645 | |
---|
[baff4da] | 646 | /** |
---|
[319cb20] | 647 | * @brief Clears the indicated STATES for @a the_thread. |
---|
[e655f7e] | 648 | * |
---|
[d4d7899] | 649 | * This routine clears the indicated STATES for @a the_thread. It performs |
---|
[ac7d5ef0] | 650 | * any necessary scheduling operations including the selection of |
---|
| 651 | * a new heir thread. |
---|
[e0f91da] | 652 | * |
---|
[e655f7e] | 653 | * - INTERRUPT LATENCY: |
---|
| 654 | * + priority map |
---|
| 655 | * + select heir |
---|
[ac7d5ef0] | 656 | */ |
---|
| 657 | void _Thread_Clear_state( |
---|
| 658 | Thread_Control *the_thread, |
---|
| 659 | States_Control state |
---|
| 660 | ); |
---|
| 661 | |
---|
[baff4da] | 662 | /** |
---|
[319cb20] | 663 | * @brief Sets the indicated @a state for @a the_thread. |
---|
[f839bf5a] | 664 | * |
---|
| 665 | * This routine sets the indicated @a state for @a the_thread. It performs |
---|
[ac7d5ef0] | 666 | * any necessary scheduling operations including the selection of |
---|
| 667 | * a new heir thread. |
---|
[f839bf5a] | 668 | * |
---|
[319cb20] | 669 | * @param[in] the_thread is the thread to set the state for. |
---|
[f839bf5a] | 670 | * @param[in] state is the state to set the_thread to. |
---|
| 671 | * |
---|
| 672 | * - INTERRUPT LATENCY: |
---|
| 673 | * + ready chain |
---|
| 674 | * + select map |
---|
[ac7d5ef0] | 675 | */ |
---|
| 676 | void _Thread_Set_state( |
---|
| 677 | Thread_Control *the_thread, |
---|
| 678 | States_Control state |
---|
| 679 | ); |
---|
| 680 | |
---|
[baff4da] | 681 | /** |
---|
[319cb20] | 682 | * @brief Sets the transient state for a thread. |
---|
[d4d7899] | 683 | * |
---|
| 684 | * This routine sets the Transient state for @a the_thread. It performs |
---|
[ac7d5ef0] | 685 | * any necessary scheduling operations including the selection of |
---|
| 686 | * a new heir thread. |
---|
[d4d7899] | 687 | * |
---|
| 688 | * @param[in] the_thread is the thread to preform the action upon. |
---|
| 689 | * |
---|
| 690 | * - INTERRUPT LATENCY: |
---|
| 691 | * + single case |
---|
[ac7d5ef0] | 692 | */ |
---|
| 693 | void _Thread_Set_transient( |
---|
| 694 | Thread_Control *the_thread |
---|
| 695 | ); |
---|
| 696 | |
---|
[baff4da] | 697 | /** |
---|
[319cb20] | 698 | * @brief Initializes enviroment for a thread. |
---|
[f839bf5a] | 699 | * |
---|
| 700 | * This routine initializes the context of @a the_thread to its |
---|
[ac7d5ef0] | 701 | * appropriate starting state. |
---|
[319cb20] | 702 | * |
---|
[f839bf5a] | 703 | * @param[in] the_thread is the pointer to the thread control block. |
---|
[ac7d5ef0] | 704 | */ |
---|
| 705 | void _Thread_Load_environment( |
---|
| 706 | Thread_Control *the_thread |
---|
| 707 | ); |
---|
| 708 | |
---|
[baff4da] | 709 | /** |
---|
[319cb20] | 710 | * @brief Wrapper function for all threads. |
---|
| 711 | * |
---|
[ac7d5ef0] | 712 | * This routine is the wrapper function for all threads. It is |
---|
| 713 | * the starting point for all threads. The user provided thread |
---|
| 714 | * entry point is invoked by this routine. Operations |
---|
| 715 | * which must be performed immediately before and after the user's |
---|
| 716 | * thread executes are found here. |
---|
[5a58b1e] | 717 | * |
---|
[e858f70] | 718 | * @note On entry, it is assumed all interrupts are blocked and that this |
---|
[5a58b1e] | 719 | * routine needs to set the initial isr level. This may or may not |
---|
| 720 | * actually be needed by the context switch routine and as a result |
---|
| 721 | * interrupts may already be at there proper level. Either way, |
---|
| 722 | * setting the initial isr level properly here is safe. |
---|
[ac7d5ef0] | 723 | */ |
---|
| 724 | void _Thread_Handler( void ); |
---|
| 725 | |
---|
[baff4da] | 726 | /** |
---|
[319cb20] | 727 | * @brief Ended the delay of a thread. |
---|
[e0f91da] | 728 | * |
---|
[ac7d5ef0] | 729 | * This routine is invoked when a thread must be unblocked at the |
---|
[3a4ae6c] | 730 | * end of a time based delay (i.e. wake after or wake when). |
---|
[bf54252] | 731 | * It is called by the watchdog handler. |
---|
| 732 | * |
---|
| 733 | * @param[in] id is the thread id |
---|
[ac7d5ef0] | 734 | */ |
---|
| 735 | void _Thread_Delay_ended( |
---|
| 736 | Objects_Id id, |
---|
| 737 | void *ignored |
---|
| 738 | ); |
---|
| 739 | |
---|
[baff4da] | 740 | /** |
---|
[319cb20] | 741 | * @brief Change the priority of a thread. |
---|
[e0f91da] | 742 | * |
---|
[1b475860] | 743 | * This routine changes the current priority of @a the_thread to |
---|
| 744 | * @a new_priority. It performs any necessary scheduling operations |
---|
[ac7d5ef0] | 745 | * including the selection of a new heir thread. |
---|
[1b475860] | 746 | * |
---|
| 747 | * @param[in] the_thread is the thread to change |
---|
| 748 | * @param[in] new_priority is the priority to set @a the_thread to |
---|
| 749 | * @param[in] prepend_it is a switch to prepend the thread |
---|
[ac7d5ef0] | 750 | */ |
---|
| 751 | void _Thread_Change_priority ( |
---|
| 752 | Thread_Control *the_thread, |
---|
[f926b34] | 753 | Priority_Control new_priority, |
---|
[484a769] | 754 | bool prepend_it |
---|
[ac7d5ef0] | 755 | ); |
---|
| 756 | |
---|
[baff4da] | 757 | /** |
---|
[319cb20] | 758 | * @brief Set thread priority. |
---|
[e0f91da] | 759 | * |
---|
[ac7d5ef0] | 760 | * This routine updates the priority related fields in the_thread |
---|
| 761 | * control block to indicate the current priority is now new_priority. |
---|
| 762 | */ |
---|
| 763 | void _Thread_Set_priority( |
---|
| 764 | Thread_Control *the_thread, |
---|
[7f6a24ab] | 765 | Priority_Control new_priority |
---|
[ac7d5ef0] | 766 | ); |
---|
| 767 | |
---|
[baff4da] | 768 | /** |
---|
[eb02f47] | 769 | * This routine updates the related suspend fields in the_thread |
---|
| 770 | * control block to indicate the current nested level. |
---|
| 771 | */ |
---|
[59eb125] | 772 | #define _Thread_Suspend( _the_thread ) \ |
---|
| 773 | _Thread_Set_state( _the_thread, STATES_SUSPENDED ) |
---|
[eb02f47] | 774 | |
---|
[baff4da] | 775 | /** |
---|
[eb02f47] | 776 | * This routine updates the related suspend fields in the_thread |
---|
| 777 | * control block to indicate the current nested level. A force |
---|
[c6b3719] | 778 | * parameter of true will force a resume and clear the suspend count. |
---|
[eb02f47] | 779 | */ |
---|
[59eb125] | 780 | #define _Thread_Resume( _the_thread ) \ |
---|
| 781 | _Thread_Clear_state( _the_thread, STATES_SUSPENDED ) |
---|
[eb02f47] | 782 | |
---|
[baff4da] | 783 | #if (CPU_PROVIDES_IDLE_THREAD_BODY == FALSE) |
---|
| 784 | /** |
---|
[adf98bd] | 785 | * This routine is the body of the system idle thread. |
---|
[93f7ea15] | 786 | * |
---|
| 787 | * NOTE: This routine is actually instantiated by confdefs.h when needed. |
---|
[adf98bd] | 788 | */ |
---|
[3aaf479] | 789 | void *_Thread_Idle_body( |
---|
| 790 | uintptr_t ignored |
---|
[adf98bd] | 791 | ); |
---|
| 792 | #endif |
---|
| 793 | |
---|
[6a07436] | 794 | /** This defines the type for a method which operates on a single thread. |
---|
[17c66867] | 795 | */ |
---|
| 796 | typedef void (*rtems_per_thread_routine)( Thread_Control * ); |
---|
| 797 | |
---|
[baff4da] | 798 | /** |
---|
[319cb20] | 799 | * @brief Iterates over all threads. |
---|
[baff4da] | 800 | * This routine iterates over all threads regardless of API and |
---|
| 801 | * invokes the specified routine. |
---|
| 802 | */ |
---|
[17c66867] | 803 | void rtems_iterate_over_all_threads( |
---|
| 804 | rtems_per_thread_routine routine |
---|
| 805 | ); |
---|
| 806 | |
---|
[78dabb69] | 807 | /** |
---|
[319cb20] | 808 | * @brief Maps thread Id to a TCB pointer. |
---|
[e0f91da] | 809 | * |
---|
[78dabb69] | 810 | * This function maps thread IDs to thread control |
---|
| 811 | * blocks. If ID corresponds to a local thread, then it |
---|
| 812 | * returns the_thread control pointer which maps to ID |
---|
[d4d7899] | 813 | * and @a location is set to OBJECTS_LOCAL. If the thread ID is |
---|
[78dabb69] | 814 | * global and resides on a remote node, then location is set |
---|
| 815 | * to OBJECTS_REMOTE, and the_thread is undefined. |
---|
| 816 | * Otherwise, location is set to OBJECTS_ERROR and |
---|
| 817 | * the_thread is undefined. |
---|
[e0f91da] | 818 | * |
---|
[d4d7899] | 819 | * @param[in] id is the id of the thread. |
---|
| 820 | * @param[in] location is the location of the block. |
---|
[78dabb69] | 821 | * |
---|
| 822 | * @note The performance of many RTEMS services depends upon |
---|
| 823 | * the quick execution of the "good object" path in this |
---|
| 824 | * routine. If there is a possibility of saving a few |
---|
| 825 | * cycles off the execution time, this routine is worth |
---|
| 826 | * further optimization attention. |
---|
| 827 | */ |
---|
| 828 | Thread_Control *_Thread_Get ( |
---|
| 829 | Objects_Id id, |
---|
| 830 | Objects_Locations *location |
---|
| 831 | ); |
---|
| 832 | |
---|
[3168deaa] | 833 | /** |
---|
[319cb20] | 834 | * @brief Cancel a blocking operation due to ISR. |
---|
[3168deaa] | 835 | * |
---|
| 836 | * This method is used to cancel a blocking operation that was |
---|
| 837 | * satisfied from an ISR while the thread executing was in the |
---|
| 838 | * process of blocking. |
---|
| 839 | * |
---|
[4012792] | 840 | * This method will restore the previous ISR disable level during the cancel |
---|
| 841 | * operation. Thus it is an implicit _ISR_Enable(). |
---|
| 842 | * |
---|
[3168deaa] | 843 | * @param[in] sync_state is the synchronization state |
---|
| 844 | * @param[in] the_thread is the thread whose blocking is canceled |
---|
| 845 | * @param[in] level is the previous ISR disable level |
---|
| 846 | * |
---|
| 847 | * @note This is a rare routine in RTEMS. It is called with |
---|
| 848 | * interrupts disabled and only when an ISR completed |
---|
| 849 | * a blocking condition in process. |
---|
| 850 | */ |
---|
| 851 | void _Thread_blocking_operation_Cancel( |
---|
| 852 | Thread_blocking_operation_States sync_state, |
---|
| 853 | Thread_Control *the_thread, |
---|
| 854 | ISR_Level level |
---|
| 855 | ); |
---|
[3a8a999] | 856 | |
---|
[1a8fde6c] | 857 | #ifndef __RTEMS_APPLICATION__ |
---|
[5e9b32b] | 858 | #include <rtems/score/thread.inl> |
---|
[1a8fde6c] | 859 | #endif |
---|
[97e2729d] | 860 | #if defined(RTEMS_MULTIPROCESSING) |
---|
[5e9b32b] | 861 | #include <rtems/score/threadmp.h> |
---|
[97e2729d] | 862 | #endif |
---|
[ac7d5ef0] | 863 | |
---|
| 864 | #ifdef __cplusplus |
---|
| 865 | } |
---|
| 866 | #endif |
---|
| 867 | |
---|
[baff4da] | 868 | /**@}*/ |
---|
| 869 | |
---|
[ac7d5ef0] | 870 | #endif |
---|
[b10825c] | 871 | /* end of include file */ |
---|