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