source: rtems/cpukit/score/include/rtems/score/thread.h @ 0a101d57

4.115
Last change on this file since 0a101d57 was 0a101d57, checked in by Joel Sherrill <joel.sherrill@…>, on 05/12/11 at 13:23:12

2011-05-12 Joel Sherrill <joel.sherrill@…>

PR 1788/cpukit

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