source: rtems/cpukit/score/include/rtems/score/thread.h @ 380c61a

4.104.115
Last change on this file since 380c61a was 517655cd, checked in by Joel Sherrill <joel.sherrill@…>, on 11/09/09 at 11:35:36

2009-11-09 Joel Sherrill <joel.sherrill@…>

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