source: rtems/cpukit/score/include/rtems/score/thread.h @ 8bef4cc

4.115
Last change on this file since 8bef4cc was 8bef4cc, checked in by Joel Sherrill <joel.sherrill@…>, on 06/24/10 at 21:27:30

2010-06-24 Gedare Bloom <giddyup44@…>

PR 1590/cpukit

  • score/Makefile.am, score/include/rtems/score/thread.h, score/src/threadtickletimeslice.c: Remove _Thread_Reset_timeslice and replaces its single use with a call to the functionally equivalent _Thread_Yield_processor().
  • score/src/threadresettimeslice.c: Removed.
  • Property mode set to 100644
File size: 27.5 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)
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}  Thread_APIs;
324
325/** This macro defines the first API which has threads. */
326#define THREAD_API_FIRST THREAD_API_RTEMS
327
328/** This macro defines the last API which has threads. */
329#define THREAD_API_LAST  THREAD_API_POSIX
330
331/**
332 *  This structure defines the Thread Control Block (TCB).
333 */
334struct Thread_Control_struct {
335  /** This field is the object management structure for each thread. */
336  Objects_Control          Object;
337  /** This field is the current execution state of this thread. */
338  States_Control           current_state;
339  /** This field is the current priority state of this thread. */
340  Priority_Control         current_priority;
341  /** This field is the base priority of this thread. */
342  Priority_Control         real_priority;
343  /** This field is the number of mutexes currently held by this thread. */
344  uint32_t                 resource_count;
345  /** This field is the blocking information for this thread. */
346  Thread_Wait_information  Wait;
347  /** This field is the Watchdog used to manage thread delays and timeouts. */
348  Watchdog_Control         Timer;
349#if defined(RTEMS_MULTIPROCESSING)
350  /** This field is the received response packet in an MP system. */
351  MP_packet_Prefix        *receive_packet;
352#endif
353#ifdef __RTEMS_STRICT_ORDER_MUTEX__
354  /** This field is the head of queue of priority inheritance mutex
355   *  held by the thread.
356   */
357  Chain_Control            lock_mutex;
358#endif
359     /*================= end of common block =================*/
360  /** This field is the number of nested suspend calls. */
361  uint32_t                              suspend_count;
362#if defined(RTEMS_MULTIPROCESSING)
363  /** This field is true if the thread is offered globally */
364  bool                                  is_global;
365#endif
366  /** This field is is true if the post task context switch should be
367   *  executed for this thread at the next context switch.
368   */
369  bool                                  do_post_task_switch_extension;
370  /** This field is true if the thread is preemptible. */
371  bool                                  is_preemptible;
372#if __RTEMS_ADA__
373  /** This field is the GNAT self context pointer. */
374  void                                 *rtems_ada_self;
375#endif
376  /** This field is the length of the time quantum that this thread is
377   *  allowed to consume.  The algorithm used to manage limits on CPU usage
378   *  is specified by budget_algorithm.
379   */
380  uint32_t                              cpu_time_budget;
381  /** This field is the algorithm used to manage this thread's time
382   *  quantum.  The algorithm may be specified as none which case,
383   *  no limit is in place.
384   */
385  Thread_CPU_budget_algorithms          budget_algorithm;
386  /** This field is the method invoked with the budgeted time is consumed. */
387  Thread_CPU_budget_algorithm_callout   budget_callout;
388  /** This field is the amount of CPU time consumed by this thread
389   *  since it was created.
390   */
391  Thread_CPU_usage_t                    cpu_time_used;
392  /** This field points to the Ready FIFO for this priority. */
393  Chain_Control                        *ready;
394  /** This field contains precalculated priority map indices. */
395  Priority_Information                  Priority_map;
396  /** This field contains information about the starting state of
397   *  this thread.
398   */
399  Thread_Start_information              Start;
400  /** This field contains the context of this thread. */
401  Context_Control                       Registers;
402#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
403  /** This field points to the floating point context for this thread.
404   *  If NULL, the thread is integer only.
405   */
406  Context_Control_fp                   *fp_context;
407#endif
408  /** This field points to the newlib reentrancy structure for this thread. */
409  struct _reent                        *libc_reent;
410  /** This array contains the API extension area pointers. */
411  void                                 *API_Extensions[ THREAD_API_LAST + 1 ];
412  /** This field points to the user extension pointers. */
413  void                                **extensions;
414  /** This field points to the set of per task variables. */
415  rtems_task_variable_t                *task_variables;
416};
417
418/**
419 *  Self for the GNU Ada Run-Time
420 */
421SCORE_EXTERN void *rtems_ada_self;
422
423/**
424 *  The following defines the information control block used to
425 *  manage this class of objects.
426 */
427SCORE_EXTERN Objects_Information _Thread_Internal_information;
428
429/**
430 *  The following define the thread control pointers used to access
431 *  and manipulate the idle thread.
432 */
433SCORE_EXTERN Thread_Control *_Thread_Idle;
434
435/**
436 *  The following context area contains the context of the "thread"
437 *  which invoked the start multitasking routine.  This context is
438 *  restored as the last action of the stop multitasking routine.  Thus
439 *  control of the processor can be returned to the environment
440 *  which initiated the system.
441 */
442SCORE_EXTERN Context_Control _Thread_BSP_context;
443
444/**
445 *  The following declares the dispatch critical section nesting
446 *  counter which is used to prevent context switches at inopportune
447 *  moments.
448 */
449SCORE_EXTERN volatile uint32_t   _Thread_Dispatch_disable_level;
450
451/**
452 *  If this is non-zero, then the post-task switch extension
453 *  is run regardless of the state of the per thread flag.
454 */
455SCORE_EXTERN uint32_t   _Thread_Do_post_task_switch_extension;
456
457/**
458 *  The following holds how many user extensions are in the system.  This
459 *  is used to determine how many user extension data areas to allocate
460 *  per thread.
461 */
462SCORE_EXTERN uint32_t   _Thread_Maximum_extensions;
463
464/**
465 *  The following is used to manage the length of a timeslice quantum.
466 */
467SCORE_EXTERN uint32_t   _Thread_Ticks_per_timeslice;
468
469/**
470 *  The following points to the array of FIFOs used to manage the
471 *  set of ready threads.
472 */
473SCORE_EXTERN Chain_Control *_Thread_Ready_chain;
474
475/**
476 *  The following points to the thread which is currently executing.
477 *  This thread is implicitly manipulated by numerous directives.
478 */
479SCORE_EXTERN Thread_Control *_Thread_Executing;
480
481/**
482 *  The following points to the highest priority ready thread
483 *  in the system.  Unless the current thread is not preemptibl,
484 *  then this thread will be context switched to when the next
485 *  dispatch occurs.
486 */
487SCORE_EXTERN Thread_Control *_Thread_Heir;
488
489/**
490 *  The following points to the thread whose floating point
491 *  context is currently loaded.
492 */
493#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
494SCORE_EXTERN Thread_Control *_Thread_Allocated_fp;
495#endif
496
497/**
498 * The C library re-enter-rant global pointer. Some C library implementations
499 * such as newlib have a single global pointer that changed during a context
500 * switch. The pointer points to that global pointer. The Thread control block
501 * holds a pointer to the task specific data.
502 */
503SCORE_EXTERN struct _reent **_Thread_libc_reent;
504
505#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
506
507  /**
508   * This contains the time since boot when the last context switch occurred.
509   * By placing it in the BSS, it will automatically be zeroed out at
510   * system initialization and does not need to be known outside this
511   * file.
512   */
513  SCORE_EXTERN Timestamp_Control _Thread_Time_of_last_context_switch;
514#endif
515
516/**
517 *  This routine performs the initialization necessary for this handler.
518 */
519void _Thread_Handler_initialization(void);
520
521/**
522 *  This routine creates the idle thread.
523 *
524 *  @warning No thread should be created before this one.
525 */
526void _Thread_Create_idle(void);
527
528/**
529 *  This routine initiates multitasking.  It is invoked only as
530 *  part of initialization and its invocation is the last act of
531 *  the non-multitasking part of the system initialization.
532 */
533void _Thread_Start_multitasking( void );
534
535/**
536 *  This routine is responsible for transferring control of the
537 *  processor from the executing thread to the heir thread.  As part
538 *  of this process, it is responsible for the following actions:
539 *
540 *     + saving the context of the executing thread
541 *     + restoring the context of the heir thread
542 *     + dispatching any signals for the resulting executing thread
543 */
544void _Thread_Dispatch( void );
545
546/**
547 *  Allocate the requested stack space for the thread.
548 *  return the actual size allocated after any adjustment
549 *  or return zero if the allocation failed.
550 *  Set the Start.stack field to the address of the stack
551 */
552
553size_t _Thread_Stack_Allocate(
554  Thread_Control *the_thread,
555  size_t          stack_size
556);
557
558/**
559 *  Deallocate the Thread's stack.
560 */
561void _Thread_Stack_Free(
562  Thread_Control *the_thread
563);
564
565/**
566 *  This routine initializes the specified the thread.  It allocates
567 *  all memory associated with this thread.  It completes by adding
568 *  the thread to the local object table so operations on this
569 *  thread id are allowed.
570 *
571 *  @note If stack_area is NULL, it is allocated from the workspace.
572 *
573 *  @note If the stack is allocated from the workspace, then it is
574 *        guaranteed to be of at least minimum size.
575 */
576bool _Thread_Initialize(
577  Objects_Information                  *information,
578  Thread_Control                       *the_thread,
579  void                                 *stack_area,
580  size_t                                stack_size,
581  bool                                  is_fp,
582  Priority_Control                      priority,
583  bool                                  is_preemptible,
584  Thread_CPU_budget_algorithms          budget_algorithm,
585  Thread_CPU_budget_algorithm_callout   budget_callout,
586  uint32_t                              isr_level,
587  Objects_Name                          name
588);
589
590/**
591 *  This routine initializes the executable information for a thread
592 *  and makes it ready to execute.  After this routine executes, the
593 *  thread competes with all other threads for CPU time.
594 */
595bool _Thread_Start(
596  Thread_Control            *the_thread,
597  Thread_Start_types         the_prototype,
598  void                      *entry_point,
599  void                      *pointer_argument,
600  Thread_Entry_numeric_type  numeric_argument
601);
602
603/**
604 *  This support routine restarts the specified task in a way that the
605 *  next time this thread executes, it will begin execution at its
606 *  original starting point.
607 *
608 *  TODO:  multiple task arg profiles
609 */
610bool _Thread_Restart(
611  Thread_Control            *the_thread,
612  void                      *pointer_argument,
613  Thread_Entry_numeric_type  numeric_argument
614);
615
616/**
617 *  This routine resets a thread to its initial state but does
618 *  not restart it.
619 */
620void _Thread_Reset(
621  Thread_Control            *the_thread,
622  void                      *pointer_argument,
623  Thread_Entry_numeric_type  numeric_argument
624);
625
626/**
627 *  This routine frees all memory associated with the specified
628 *  thread and removes it from the local object table so no further
629 *  operations on this thread are allowed.
630 */
631void _Thread_Close(
632  Objects_Information  *information,
633  Thread_Control       *the_thread
634);
635
636/**
637 *  This routine removes any set states for the_thread.  It performs
638 *  any necessary scheduling operations including the selection of
639 *  a new heir thread.
640 */
641void _Thread_Ready(
642  Thread_Control *the_thread
643);
644
645/**
646 *  This routine clears 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_Clear_state(
651  Thread_Control *the_thread,
652  States_Control  state
653);
654
655/**
656 *  This routine sets the indicated states for the_thread.  It performs
657 *  any necessary scheduling operations including the selection of
658 *  a new heir thread.
659 */
660void _Thread_Set_state(
661  Thread_Control *the_thread,
662  States_Control  state
663);
664
665/**
666 *  This routine sets the TRANSIENT state for the_thread.  It performs
667 *  any necessary scheduling operations including the selection of
668 *  a new heir thread.
669 */
670void _Thread_Set_transient(
671  Thread_Control *the_thread
672);
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 initializes the context of the_thread to its
690 *  appropriate starting state.
691 */
692void _Thread_Load_environment(
693  Thread_Control *the_thread
694);
695
696/**
697 *  This routine is the wrapper function for all threads.  It is
698 *  the starting point for all threads.  The user provided thread
699 *  entry point is invoked by this routine.  Operations
700 *  which must be performed immediately before and after the user's
701 *  thread executes are found here.
702 */
703void _Thread_Handler( void );
704
705/**
706 *  This routine is invoked when a thread must be unblocked at the
707 *  end of a time based delay (i.e. wake after or wake when).
708 */
709void _Thread_Delay_ended(
710  Objects_Id  id,
711  void       *ignored
712);
713
714/**
715 *  This routine changes the current priority of the_thread to
716 *  new_priority.  It performs any necessary scheduling operations
717 *  including the selection of a new heir thread.
718 */
719void _Thread_Change_priority (
720  Thread_Control   *the_thread,
721  Priority_Control  new_priority,
722  bool              prepend_it
723);
724
725/**
726 *  This routine updates the priority related fields in the_thread
727 *  control block to indicate the current priority is now new_priority.
728 */
729void _Thread_Set_priority(
730  Thread_Control   *the_thread,
731  Priority_Control  new_priority
732);
733
734/**
735 *  This routine updates the related suspend fields in the_thread
736 *  control block to indicate the current nested level.
737 */
738void _Thread_Suspend(
739  Thread_Control   *the_thread
740);
741
742/**
743 *  This routine updates the related suspend fields in the_thread
744 *  control block to indicate the current nested level.  A force
745 *  parameter of true will force a resume and clear the suspend count.
746 */
747void _Thread_Resume(
748  Thread_Control   *the_thread,
749  bool              force
750);
751
752/**
753 *  This routine evaluates the current scheduling information for the
754 *  system and determines if a context switch is required.  This
755 *  is usually called after changing an execution mode such as preemptability
756 *  for a thread.
757 */
758bool _Thread_Evaluate_mode( void );
759
760#if (CPU_PROVIDES_IDLE_THREAD_BODY == FALSE)
761/**
762 *  This routine is the body of the system idle thread.
763 *
764 *  NOTE: This routine is actually instantiated by confdefs.h when needed.
765 */
766void *_Thread_Idle_body(
767  uintptr_t  ignored
768);
769#endif
770
771/**  This defines the type for a method which operates on a single thread.
772 */
773typedef void (*rtems_per_thread_routine)( Thread_Control * );
774
775/**
776 *  This routine iterates over all threads regardless of API and
777 *  invokes the specified routine.
778 */
779void rtems_iterate_over_all_threads(
780  rtems_per_thread_routine routine
781);
782
783/**
784 *  This function maps thread IDs to thread control
785 *  blocks.  If ID corresponds to a local thread, then it
786 *  returns the_thread control pointer which maps to ID
787 *  and location is set to OBJECTS_LOCAL.  If the thread ID is
788 *  global and resides on a remote node, then location is set
789 *  to OBJECTS_REMOTE, and the_thread is undefined.
790 *  Otherwise, location is set to OBJECTS_ERROR and
791 *  the_thread is undefined.
792 *
793 *  @note  The performance of many RTEMS services depends upon
794 *         the quick execution of the "good object" path in this
795 *         routine.  If there is a possibility of saving a few
796 *         cycles off the execution time, this routine is worth
797 *         further optimization attention.
798 */
799Thread_Control *_Thread_Get (
800  Objects_Id         id,
801  Objects_Locations *location
802);
803
804/**
805 *  @brief Cancel a blocking operation due to ISR
806 *
807 *  This method is used to cancel a blocking operation that was
808 *  satisfied from an ISR while the thread executing was in the
809 *  process of blocking.
810 *
811 *  @param[in] sync_state is the synchronization state
812 *  @param[in] the_thread is the thread whose blocking is canceled
813 *  @param[in] level is the previous ISR disable level
814 *
815 *  @note This is a rare routine in RTEMS.  It is called with
816 *        interrupts disabled and only when an ISR completed
817 *        a blocking condition in process.
818 */
819void _Thread_blocking_operation_Cancel(
820  Thread_blocking_operation_States  sync_state,
821  Thread_Control                   *the_thread,
822  ISR_Level                         level
823);
824
825#ifndef __RTEMS_APPLICATION__
826#include <rtems/score/thread.inl>
827#endif
828#if defined(RTEMS_MULTIPROCESSING)
829#include <rtems/score/threadmp.h>
830#endif
831
832#ifdef __cplusplus
833}
834#endif
835
836/**@}*/
837
838#endif
839/* end of include file */
Note: See TracBrowser for help on using the repository browser.