source: rtems/cpukit/score/include/rtems/score/thread.h @ 790b50b

4.104.115
Last change on this file since 790b50b was 790b50b, checked in by Joel Sherrill <joel.sherrill@…>, on 12/17/08 at 22:46:05

2008-12-17 Joel Sherrill <joel.sherrill@…>

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