source: rtems/cpukit/score/include/rtems/score/thread.h @ 099cdd5

4.115
Last change on this file since 099cdd5 was b3d0e8bf, checked in by Joel Sherrill <joel.sherrill@…>, on 06/17/10 at 17:20:55

2010-06-17 Joel Sherrill <joel.sherrill@…>

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