1 | /** |
---|
2 | * @file rtems/score/thread.h |
---|
3 | * |
---|
4 | * This include file contains all constants and structures associated |
---|
5 | * with the thread control block. |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2004. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | * |
---|
16 | * $Id$ |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_SCORE_THREAD_H |
---|
20 | #define _RTEMS_SCORE_THREAD_H |
---|
21 | |
---|
22 | /** |
---|
23 | * @defgroup ScoreThread Thread Handler |
---|
24 | * |
---|
25 | * This group contains functionality which XXX |
---|
26 | */ |
---|
27 | /**@{*/ |
---|
28 | |
---|
29 | #ifdef __cplusplus |
---|
30 | extern "C" { |
---|
31 | #endif |
---|
32 | |
---|
33 | #include <rtems/score/context.h> |
---|
34 | #include <rtems/score/cpu.h> |
---|
35 | #if defined(RTEMS_MULTIPROCESSING) |
---|
36 | #include <rtems/score/mppkt.h> |
---|
37 | #endif |
---|
38 | #include <rtems/score/object.h> |
---|
39 | #include <rtems/score/priority.h> |
---|
40 | #include <rtems/score/stack.h> |
---|
41 | #include <rtems/score/states.h> |
---|
42 | #include <rtems/score/tod.h> |
---|
43 | #include <rtems/score/tqdata.h> |
---|
44 | #include <rtems/score/watchdog.h> |
---|
45 | |
---|
46 | /** |
---|
47 | * The following defines the "return type" of a thread. |
---|
48 | * |
---|
49 | * @note This cannot always be right. Some APIs have void |
---|
50 | * tasks/threads, others return pointers, others may |
---|
51 | * return a numeric value. Hopefully a pointer is |
---|
52 | * always at least as big as an uint32_t . :) |
---|
53 | */ |
---|
54 | typedef void *Thread; |
---|
55 | |
---|
56 | /** |
---|
57 | * The following defines the ways in which the entry point for a |
---|
58 | * thread can be invoked. Basically, it can be passed any |
---|
59 | * combination/permutation of a pointer and an uint32_t value. |
---|
60 | * |
---|
61 | * @note For now, we are ignoring the return type. |
---|
62 | */ |
---|
63 | typedef enum { |
---|
64 | THREAD_START_NUMERIC, |
---|
65 | THREAD_START_POINTER, |
---|
66 | THREAD_START_BOTH_POINTER_FIRST, |
---|
67 | THREAD_START_BOTH_NUMERIC_FIRST |
---|
68 | } Thread_Start_types; |
---|
69 | |
---|
70 | /** |
---|
71 | */ |
---|
72 | typedef Thread ( *Thread_Entry )(); /* basic type */ |
---|
73 | |
---|
74 | typedef Thread ( *Thread_Entry_numeric )( uint32_t ); |
---|
75 | |
---|
76 | /** |
---|
77 | */ |
---|
78 | typedef Thread ( *Thread_Entry_pointer )( void * ); |
---|
79 | |
---|
80 | /** |
---|
81 | */ |
---|
82 | typedef Thread ( *Thread_Entry_both_pointer_first )( void *, uint32_t ); |
---|
83 | |
---|
84 | /** |
---|
85 | */ |
---|
86 | typedef Thread ( *Thread_Entry_both_numeric_first )( uint32_t , void * ); |
---|
87 | |
---|
88 | /** |
---|
89 | * The following lists the algorithms used to manage the thread cpu budget. |
---|
90 | * |
---|
91 | * Reset Timeslice: At each context switch, reset the time quantum. |
---|
92 | * Exhaust Timeslice: Only reset the quantum once it is consumed. |
---|
93 | * Callout: Execute routine when budget is consumed. |
---|
94 | */ |
---|
95 | typedef enum { |
---|
96 | THREAD_CPU_BUDGET_ALGORITHM_NONE, |
---|
97 | THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE, |
---|
98 | THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE, |
---|
99 | THREAD_CPU_BUDGET_ALGORITHM_CALLOUT |
---|
100 | } Thread_CPU_budget_algorithms; |
---|
101 | |
---|
102 | /** |
---|
103 | */ |
---|
104 | typedef struct Thread_Control_struct Thread_Control; |
---|
105 | |
---|
106 | /** |
---|
107 | */ |
---|
108 | typedef void (*Thread_CPU_budget_algorithm_callout )( Thread_Control * ); |
---|
109 | |
---|
110 | /** @brief Per Task Variable Manager Structure Forward Reference |
---|
111 | * |
---|
112 | * Forward reference to the per task variable structure. |
---|
113 | */ |
---|
114 | struct rtems_task_variable_tt; |
---|
115 | |
---|
116 | /** @brief Per Task Variable Manager Structure |
---|
117 | * |
---|
118 | * This is the internal structure used to manager per Task Variables. |
---|
119 | */ |
---|
120 | struct rtems_task_variable_tt { |
---|
121 | /** This field points to the next per task variable for this task. */ |
---|
122 | struct rtems_task_variable_tt *next; |
---|
123 | /** This field points to the physical memory location of this per |
---|
124 | * task variable. |
---|
125 | */ |
---|
126 | void **ptr; |
---|
127 | /** This field is to the global value for this per task variable. */ |
---|
128 | void *gval; |
---|
129 | /** This field is to this thread's value for this per task variable. */ |
---|
130 | void *tval; |
---|
131 | /** This field points to the destructor for this per task variable. */ |
---|
132 | void (*dtor)(void *); |
---|
133 | }; |
---|
134 | |
---|
135 | /** |
---|
136 | */ |
---|
137 | typedef struct rtems_task_variable_tt rtems_task_variable_t; |
---|
138 | |
---|
139 | /** |
---|
140 | * The following structure contains the information which defines |
---|
141 | * the starting state of a thread. |
---|
142 | */ |
---|
143 | typedef struct { |
---|
144 | Thread_Entry entry_point; /* starting thread address */ |
---|
145 | Thread_Start_types prototype; /* how task is invoked */ |
---|
146 | void *pointer_argument; /* pointer argument */ |
---|
147 | uint32_t numeric_argument; /* numeric argument */ |
---|
148 | /* initial execution modes */ |
---|
149 | boolean is_preemptible; |
---|
150 | Thread_CPU_budget_algorithms budget_algorithm; |
---|
151 | Thread_CPU_budget_algorithm_callout budget_callout; |
---|
152 | uint32_t isr_level; |
---|
153 | Priority_Control initial_priority; /* initial priority */ |
---|
154 | boolean core_allocated_stack; |
---|
155 | Stack_Control Initial_stack; /* stack information */ |
---|
156 | #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) |
---|
157 | void *fp_context; /* initial FP context area address */ |
---|
158 | #endif |
---|
159 | void *stack; /* initial stack area address */ |
---|
160 | } Thread_Start_information; |
---|
161 | |
---|
162 | /** |
---|
163 | * The following structure contains the information necessary to manage |
---|
164 | * a thread which it is waiting for a resource. |
---|
165 | */ |
---|
166 | #define THREAD_STATUS_PROXY_BLOCKING 0x1111111 |
---|
167 | |
---|
168 | /** @brief Thread Blocking Management Information |
---|
169 | * |
---|
170 | * This contains the information required to manage a thread while it is |
---|
171 | * blocked and to return information to it. |
---|
172 | */ |
---|
173 | typedef struct { |
---|
174 | /** This field is the Id of the object this thread is waiting upon. */ |
---|
175 | Objects_Id id; |
---|
176 | /** This field is used to return an integer while when blocked. */ |
---|
177 | uint32_t count; |
---|
178 | /** This field is the first pointer to a user return argument. */ |
---|
179 | void *return_argument; |
---|
180 | /** This field is the second pointer to a user return argument. */ |
---|
181 | void *return_argument_1; |
---|
182 | /** This field contains any options in effect on this blocking operation. */ |
---|
183 | uint32_t option; |
---|
184 | /** This field will contain the return status from a blocking operation. |
---|
185 | * |
---|
186 | * @note The following assumes that all API return codes can be |
---|
187 | * treated as an uint32_t. |
---|
188 | */ |
---|
189 | uint32_t return_code; |
---|
190 | |
---|
191 | /** This field is the chain header for the second through Nth tasks |
---|
192 | * of the same priority blocked waiting on the same object. |
---|
193 | */ |
---|
194 | Chain_Control Block2n; |
---|
195 | /** This field points to the thread queue on which this thread is blocked. */ |
---|
196 | Thread_queue_Control *queue; |
---|
197 | } Thread_Wait_information; |
---|
198 | |
---|
199 | /** |
---|
200 | * The following defines the control block used to manage |
---|
201 | * each thread proxy. |
---|
202 | * |
---|
203 | * @note It is critical that proxies and threads have identical |
---|
204 | * memory images for the shared part. |
---|
205 | */ |
---|
206 | typedef struct { |
---|
207 | Objects_Control Object; |
---|
208 | States_Control current_state; |
---|
209 | Priority_Control current_priority; |
---|
210 | Priority_Control real_priority; |
---|
211 | uint32_t resource_count; |
---|
212 | Thread_Wait_information Wait; |
---|
213 | Watchdog_Control Timer; |
---|
214 | #if defined(RTEMS_MULTIPROCESSING) |
---|
215 | MP_packet_Prefix *receive_packet; |
---|
216 | #endif |
---|
217 | /****************** end of common block ********************/ |
---|
218 | Chain_Node Active; |
---|
219 | } Thread_Proxy_control; |
---|
220 | |
---|
221 | /** |
---|
222 | * The following record defines the control block used |
---|
223 | * to manage each thread. |
---|
224 | * |
---|
225 | * @note It is critical that proxies and threads have identical |
---|
226 | * memory images for the shared part. |
---|
227 | */ |
---|
228 | typedef enum { |
---|
229 | THREAD_API_RTEMS, |
---|
230 | THREAD_API_POSIX, |
---|
231 | THREAD_API_ITRON |
---|
232 | } Thread_APIs; |
---|
233 | |
---|
234 | /** |
---|
235 | */ |
---|
236 | #define THREAD_API_FIRST THREAD_API_RTEMS |
---|
237 | |
---|
238 | /** |
---|
239 | */ |
---|
240 | #define THREAD_API_LAST THREAD_API_ITRON |
---|
241 | |
---|
242 | /** |
---|
243 | */ |
---|
244 | struct Thread_Control_struct { |
---|
245 | Objects_Control Object; |
---|
246 | States_Control current_state; |
---|
247 | Priority_Control current_priority; |
---|
248 | Priority_Control real_priority; |
---|
249 | uint32_t resource_count; |
---|
250 | Thread_Wait_information Wait; |
---|
251 | Watchdog_Control Timer; |
---|
252 | #if defined(RTEMS_MULTIPROCESSING) |
---|
253 | MP_packet_Prefix *receive_packet; |
---|
254 | #endif |
---|
255 | /****************** end of common block ********************/ |
---|
256 | uint32_t suspend_count; |
---|
257 | boolean is_global; |
---|
258 | boolean do_post_task_switch_extension; |
---|
259 | |
---|
260 | boolean is_preemptible; |
---|
261 | void *rtems_ada_self; |
---|
262 | uint32_t cpu_time_budget; |
---|
263 | Thread_CPU_budget_algorithms budget_algorithm; |
---|
264 | Thread_CPU_budget_algorithm_callout budget_callout; |
---|
265 | |
---|
266 | uint32_t ticks_executed; |
---|
267 | Chain_Control *ready; |
---|
268 | Priority_Information Priority_map; |
---|
269 | Thread_Start_information Start; |
---|
270 | Context_Control Registers; |
---|
271 | #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) |
---|
272 | void *fp_context; |
---|
273 | #endif |
---|
274 | struct _reent *libc_reent; |
---|
275 | void *API_Extensions[ THREAD_API_LAST + 1 ]; |
---|
276 | void **extensions; |
---|
277 | rtems_task_variable_t *task_variables; |
---|
278 | }; |
---|
279 | |
---|
280 | /** |
---|
281 | * Self for the GNU Ada Run-Time |
---|
282 | */ |
---|
283 | SCORE_EXTERN void *rtems_ada_self; |
---|
284 | |
---|
285 | /** |
---|
286 | * The following defines the information control block used to |
---|
287 | * manage this class of objects. |
---|
288 | */ |
---|
289 | SCORE_EXTERN Objects_Information _Thread_Internal_information; |
---|
290 | |
---|
291 | /** |
---|
292 | * The following define the thread control pointers used to access |
---|
293 | * and manipulate the idle thread. |
---|
294 | */ |
---|
295 | SCORE_EXTERN Thread_Control *_Thread_Idle; |
---|
296 | |
---|
297 | /** |
---|
298 | * The following context area contains the context of the "thread" |
---|
299 | * which invoked the start multitasking routine. This context is |
---|
300 | * restored as the last action of the stop multitasking routine. Thus |
---|
301 | * control of the processor can be returned to the environment |
---|
302 | * which initiated the system. |
---|
303 | */ |
---|
304 | SCORE_EXTERN Context_Control _Thread_BSP_context; |
---|
305 | |
---|
306 | /*** |
---|
307 | * The following declares the dispatch critical section nesting |
---|
308 | * counter which is used to prevent context switches at inopportune |
---|
309 | * moments. |
---|
310 | */ |
---|
311 | SCORE_EXTERN volatile uint32_t _Thread_Dispatch_disable_level; |
---|
312 | |
---|
313 | /** |
---|
314 | * If this is non-zero, then the post-task switch extension |
---|
315 | * is run regardless of the state of the per thread flag. |
---|
316 | */ |
---|
317 | SCORE_EXTERN uint32_t _Thread_Do_post_task_switch_extension; |
---|
318 | |
---|
319 | /** |
---|
320 | * The following holds how many user extensions are in the system. This |
---|
321 | * is used to determine how many user extension data areas to allocate |
---|
322 | * per thread. |
---|
323 | */ |
---|
324 | SCORE_EXTERN uint32_t _Thread_Maximum_extensions; |
---|
325 | |
---|
326 | /** |
---|
327 | * The following is used to manage the length of a timeslice quantum. |
---|
328 | */ |
---|
329 | SCORE_EXTERN uint32_t _Thread_Ticks_per_timeslice; |
---|
330 | |
---|
331 | /** |
---|
332 | * The following points to the array of FIFOs used to manage the |
---|
333 | * set of ready threads. |
---|
334 | */ |
---|
335 | SCORE_EXTERN Chain_Control *_Thread_Ready_chain; |
---|
336 | |
---|
337 | /** |
---|
338 | * The following points to the thread which is currently executing. |
---|
339 | * This thread is implicitly manipulated by numerous directives. |
---|
340 | */ |
---|
341 | SCORE_EXTERN Thread_Control *_Thread_Executing; |
---|
342 | |
---|
343 | /** |
---|
344 | * The following points to the highest priority ready thread |
---|
345 | * in the system. Unless the current thread is not preemptibl, |
---|
346 | * then this thread will be context switched to when the next |
---|
347 | * dispatch occurs. |
---|
348 | */ |
---|
349 | SCORE_EXTERN Thread_Control *_Thread_Heir; |
---|
350 | |
---|
351 | /** |
---|
352 | * The following points to the thread whose floating point |
---|
353 | * context is currently loaded. |
---|
354 | */ |
---|
355 | #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) |
---|
356 | SCORE_EXTERN Thread_Control *_Thread_Allocated_fp; |
---|
357 | #endif |
---|
358 | |
---|
359 | /** |
---|
360 | * The C library re-enter-rant global pointer. Some C library implementations |
---|
361 | * such as newlib have a single global pointer that changed during a context |
---|
362 | * switch. The pointer points to that global pointer. The Thread control block |
---|
363 | * holds a pointer to the task specific data. |
---|
364 | */ |
---|
365 | SCORE_EXTERN struct _reent **_Thread_libc_reent; |
---|
366 | |
---|
367 | /** |
---|
368 | * This routine performs the initialization necessary for this handler. |
---|
369 | */ |
---|
370 | void _Thread_Handler_initialization ( |
---|
371 | uint32_t ticks_per_timeslice, |
---|
372 | uint32_t maximum_extensions, |
---|
373 | uint32_t maximum_proxies |
---|
374 | ); |
---|
375 | |
---|
376 | /** |
---|
377 | * This routine creates the idle thread. |
---|
378 | * |
---|
379 | * @warning No thread should be created before this one. |
---|
380 | */ |
---|
381 | void _Thread_Create_idle( void ); |
---|
382 | |
---|
383 | /** |
---|
384 | * This routine initiates multitasking. It is invoked only as |
---|
385 | * part of initialization and its invocation is the last act of |
---|
386 | * the non-multitasking part of the system initialization. |
---|
387 | */ |
---|
388 | void _Thread_Start_multitasking( void ); |
---|
389 | |
---|
390 | /** |
---|
391 | * This routine is responsible for transferring control of the |
---|
392 | * processor from the executing thread to the heir thread. As part |
---|
393 | * of this process, it is responsible for the following actions: |
---|
394 | * |
---|
395 | * + saving the context of the executing thread |
---|
396 | * + restoring the context of the heir thread |
---|
397 | * + dispatching any signals for the resulting executing thread |
---|
398 | */ |
---|
399 | void _Thread_Dispatch( void ); |
---|
400 | |
---|
401 | /** |
---|
402 | * Allocate the requested stack space for the thread. |
---|
403 | * return the actual size allocated after any adjustment |
---|
404 | * or return zero if the allocation failed. |
---|
405 | * Set the Start.stack field to the address of the stack |
---|
406 | */ |
---|
407 | |
---|
408 | uint32_t _Thread_Stack_Allocate( |
---|
409 | Thread_Control *the_thread, |
---|
410 | uint32_t stack_size |
---|
411 | ); |
---|
412 | |
---|
413 | /** |
---|
414 | * Deallocate the Thread's stack. |
---|
415 | */ |
---|
416 | void _Thread_Stack_Free( |
---|
417 | Thread_Control *the_thread |
---|
418 | ); |
---|
419 | |
---|
420 | /** |
---|
421 | * This routine initializes the specified the thread. It allocates |
---|
422 | * all memory associated with this thread. It completes by adding |
---|
423 | * the thread to the local object table so operations on this |
---|
424 | * thread id are allowed. |
---|
425 | * |
---|
426 | * @note If stack_area is NULL, it is allocated from the workspace. |
---|
427 | * |
---|
428 | * @note If the stack is allocated from the workspace, then it is |
---|
429 | * guaranteed to be of at least minimum size. |
---|
430 | */ |
---|
431 | boolean _Thread_Initialize( |
---|
432 | Objects_Information *information, |
---|
433 | Thread_Control *the_thread, |
---|
434 | void *stack_area, |
---|
435 | uint32_t stack_size, |
---|
436 | boolean is_fp, |
---|
437 | Priority_Control priority, |
---|
438 | boolean is_preemptible, |
---|
439 | Thread_CPU_budget_algorithms budget_algorithm, |
---|
440 | Thread_CPU_budget_algorithm_callout budget_callout, |
---|
441 | uint32_t isr_level, |
---|
442 | Objects_Name name |
---|
443 | ); |
---|
444 | |
---|
445 | /** |
---|
446 | * This routine initializes the executable information for a thread |
---|
447 | * and makes it ready to execute. After this routine executes, the |
---|
448 | * thread competes with all other threads for CPU time. |
---|
449 | */ |
---|
450 | boolean _Thread_Start( |
---|
451 | Thread_Control *the_thread, |
---|
452 | Thread_Start_types the_prototype, |
---|
453 | void *entry_point, |
---|
454 | void *pointer_argument, |
---|
455 | uint32_t numeric_argument |
---|
456 | ); |
---|
457 | |
---|
458 | /** |
---|
459 | * This support routine restarts the specified task in a way that the |
---|
460 | * next time this thread executes, it will begin execution at its |
---|
461 | * original starting point. |
---|
462 | * |
---|
463 | * TODO: multiple task arg profiles |
---|
464 | */ |
---|
465 | boolean _Thread_Restart( |
---|
466 | Thread_Control *the_thread, |
---|
467 | void *pointer_argument, |
---|
468 | uint32_t numeric_argument |
---|
469 | ); |
---|
470 | |
---|
471 | /** |
---|
472 | * This routine resets a thread to its initial state but does |
---|
473 | * not restart it. |
---|
474 | */ |
---|
475 | void _Thread_Reset( |
---|
476 | Thread_Control *the_thread, |
---|
477 | void *pointer_argument, |
---|
478 | uint32_t numeric_argument |
---|
479 | ); |
---|
480 | |
---|
481 | /** |
---|
482 | * This routine frees all memory associated with the specified |
---|
483 | * thread and removes it from the local object table so no further |
---|
484 | * operations on this thread are allowed. |
---|
485 | */ |
---|
486 | void _Thread_Close( |
---|
487 | Objects_Information *information, |
---|
488 | Thread_Control *the_thread |
---|
489 | ); |
---|
490 | |
---|
491 | /** |
---|
492 | * This routine removes any set states for the_thread. It performs |
---|
493 | * any necessary scheduling operations including the selection of |
---|
494 | * a new heir thread. |
---|
495 | */ |
---|
496 | void _Thread_Ready( |
---|
497 | Thread_Control *the_thread |
---|
498 | ); |
---|
499 | |
---|
500 | /** |
---|
501 | * This routine clears the indicated STATES for the_thread. It performs |
---|
502 | * any necessary scheduling operations including the selection of |
---|
503 | * a new heir thread. |
---|
504 | */ |
---|
505 | void _Thread_Clear_state( |
---|
506 | Thread_Control *the_thread, |
---|
507 | States_Control state |
---|
508 | ); |
---|
509 | |
---|
510 | /** |
---|
511 | * This routine sets the indicated states for the_thread. It performs |
---|
512 | * any necessary scheduling operations including the selection of |
---|
513 | * a new heir thread. |
---|
514 | */ |
---|
515 | void _Thread_Set_state( |
---|
516 | Thread_Control *the_thread, |
---|
517 | States_Control state |
---|
518 | ); |
---|
519 | |
---|
520 | /** |
---|
521 | * This routine sets the TRANSIENT state for the_thread. It performs |
---|
522 | * any necessary scheduling operations including the selection of |
---|
523 | * a new heir thread. |
---|
524 | */ |
---|
525 | void _Thread_Set_transient( |
---|
526 | Thread_Control *the_thread |
---|
527 | ); |
---|
528 | |
---|
529 | /** |
---|
530 | * This routine is invoked upon expiration of the currently |
---|
531 | * executing thread's timeslice. If no other thread's are ready |
---|
532 | * at the priority of the currently executing thread, then the |
---|
533 | * executing thread's timeslice is reset. Otherwise, the |
---|
534 | * currently executing thread is placed at the rear of the |
---|
535 | * FIFO for this priority and a new heir is selected. |
---|
536 | */ |
---|
537 | void _Thread_Reset_timeslice( void ); |
---|
538 | |
---|
539 | /** |
---|
540 | * This routine is invoked as part of processing each clock tick. |
---|
541 | * It is responsible for determining if the current thread allows |
---|
542 | * timeslicing and, if so, when its timeslice expires. |
---|
543 | */ |
---|
544 | void _Thread_Tickle_timeslice( void ); |
---|
545 | |
---|
546 | /** |
---|
547 | * This routine is invoked when a thread wishes to voluntarily |
---|
548 | * transfer control of the processor to another thread of equal |
---|
549 | * or greater priority. |
---|
550 | */ |
---|
551 | void _Thread_Yield_processor( void ); |
---|
552 | |
---|
553 | /** |
---|
554 | * This routine is invoked to rotate the ready queue for the |
---|
555 | * given priority. It can be used to yeild the processor |
---|
556 | * by rotating the executing threads ready queue. |
---|
557 | */ |
---|
558 | void _Thread_Rotate_Ready_Queue( |
---|
559 | Priority_Control priority |
---|
560 | ); |
---|
561 | |
---|
562 | /** |
---|
563 | * This routine initializes the context of the_thread to its |
---|
564 | * appropriate starting state. |
---|
565 | */ |
---|
566 | void _Thread_Load_environment( |
---|
567 | Thread_Control *the_thread |
---|
568 | ); |
---|
569 | |
---|
570 | /** |
---|
571 | * This routine is the wrapper function for all threads. It is |
---|
572 | * the starting point for all threads. The user provided thread |
---|
573 | * entry point is invoked by this routine. Operations |
---|
574 | * which must be performed immediately before and after the user's |
---|
575 | * thread executes are found here. |
---|
576 | */ |
---|
577 | void _Thread_Handler( void ); |
---|
578 | |
---|
579 | /** |
---|
580 | * This routine is invoked when a thread must be unblocked at the |
---|
581 | * end of a time based delay (i.e. wake after or wake when). |
---|
582 | */ |
---|
583 | void _Thread_Delay_ended( |
---|
584 | Objects_Id id, |
---|
585 | void *ignored |
---|
586 | ); |
---|
587 | |
---|
588 | /** |
---|
589 | * This routine changes the current priority of the_thread to |
---|
590 | * new_priority. It performs any necessary scheduling operations |
---|
591 | * including the selection of a new heir thread. |
---|
592 | */ |
---|
593 | void _Thread_Change_priority ( |
---|
594 | Thread_Control *the_thread, |
---|
595 | Priority_Control new_priority, |
---|
596 | boolean prepend_it |
---|
597 | ); |
---|
598 | |
---|
599 | /** |
---|
600 | * This routine updates the priority related fields in the_thread |
---|
601 | * control block to indicate the current priority is now new_priority. |
---|
602 | */ |
---|
603 | void _Thread_Set_priority( |
---|
604 | Thread_Control *the_thread, |
---|
605 | Priority_Control new_priority |
---|
606 | ); |
---|
607 | |
---|
608 | /** |
---|
609 | * This routine updates the related suspend fields in the_thread |
---|
610 | * control block to indicate the current nested level. |
---|
611 | */ |
---|
612 | void _Thread_Suspend( |
---|
613 | Thread_Control *the_thread |
---|
614 | ); |
---|
615 | |
---|
616 | /** |
---|
617 | * This routine updates the related suspend fields in the_thread |
---|
618 | * control block to indicate the current nested level. A force |
---|
619 | * parameter of TRUE will force a resume and clear the suspend count. |
---|
620 | */ |
---|
621 | void _Thread_Resume( |
---|
622 | Thread_Control *the_thread, |
---|
623 | boolean force |
---|
624 | ); |
---|
625 | |
---|
626 | /** |
---|
627 | * This routine evaluates the current scheduling information for the |
---|
628 | * system and determines if a context switch is required. This |
---|
629 | * is usually called after changing an execution mode such as preemptability |
---|
630 | * for a thread. |
---|
631 | */ |
---|
632 | boolean _Thread_Evaluate_mode( void ); |
---|
633 | |
---|
634 | #ifndef RTEMS_INLINES |
---|
635 | /** |
---|
636 | * @note If we are not using static inlines, this must be a real |
---|
637 | * subroutine call. |
---|
638 | */ |
---|
639 | Thread_Control *_Thread_Get ( |
---|
640 | Objects_Id id, |
---|
641 | Objects_Locations *location |
---|
642 | ); |
---|
643 | #endif |
---|
644 | |
---|
645 | #if (CPU_PROVIDES_IDLE_THREAD_BODY == FALSE) |
---|
646 | /** |
---|
647 | * This routine is the body of the system idle thread. |
---|
648 | */ |
---|
649 | Thread _Thread_Idle_body( |
---|
650 | uint32_t ignored |
---|
651 | ); |
---|
652 | #endif |
---|
653 | |
---|
654 | /** |
---|
655 | */ |
---|
656 | typedef void (*rtems_per_thread_routine)( Thread_Control * ); |
---|
657 | |
---|
658 | /** |
---|
659 | * This routine iterates over all threads regardless of API and |
---|
660 | * invokes the specified routine. |
---|
661 | */ |
---|
662 | void rtems_iterate_over_all_threads( |
---|
663 | rtems_per_thread_routine routine |
---|
664 | ); |
---|
665 | |
---|
666 | #ifndef __RTEMS_APPLICATION__ |
---|
667 | #include <rtems/score/thread.inl> |
---|
668 | #endif |
---|
669 | #if defined(RTEMS_MULTIPROCESSING) |
---|
670 | #include <rtems/score/threadmp.h> |
---|
671 | #endif |
---|
672 | |
---|
673 | #ifdef __cplusplus |
---|
674 | } |
---|
675 | #endif |
---|
676 | |
---|
677 | /**@}*/ |
---|
678 | |
---|
679 | #endif |
---|
680 | /* end of include file */ |
---|