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