source: rtems/cpukit/score/include/rtems/score/thread.h @ dacdda30

4.115
Last change on this file since dacdda30 was dacdda30, checked in by Ralf Corsepius <ralf.corsepius@…>, on 05/24/11 at 02:44:58

Remove white-spaces.

  • Property mode set to 100644
File size: 27.7 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#if defined(RTEMS_SMP)
468  /**
469   * The following declares the smp spinlock to be used to control
470   * the dispatch critical section accesses across cpus.
471   */
472  SCORE_EXTERN SMP_lock_spinlock_nested_Control _Thread_Dispatch_disable_level_lock;
473#endif
474
475/**
476 *  The following holds how many user extensions are in the system.  This
477 *  is used to determine how many user extension data areas to allocate
478 *  per thread.
479 */
480SCORE_EXTERN uint32_t   _Thread_Maximum_extensions;
481
482/**
483 *  The following is used to manage the length of a timeslice quantum.
484 */
485SCORE_EXTERN uint32_t   _Thread_Ticks_per_timeslice;
486
487/**
488 *  The following points to the thread whose floating point
489 *  context is currently loaded.
490 */
491#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
492SCORE_EXTERN Thread_Control *_Thread_Allocated_fp;
493#endif
494
495/**
496 * The C library re-enter-rant global pointer. Some C library implementations
497 * such as newlib have a single global pointer that changed during a context
498 * switch. The pointer points to that global pointer. The Thread control block
499 * holds a pointer to the task specific data.
500 */
501SCORE_EXTERN struct _reent **_Thread_libc_reent;
502
503
504/**
505 *  This routine performs the initialization necessary for this handler.
506 */
507void _Thread_Handler_initialization(void);
508
509/**
510 *  This routine creates the idle thread.
511 *
512 *  @warning No thread should be created before this one.
513 */
514void _Thread_Create_idle(void);
515
516/**
517 *  This routine initiates multitasking.  It is invoked only as
518 *  part of initialization and its invocation is the last act of
519 *  the non-multitasking part of the system initialization.
520 */
521void _Thread_Start_multitasking( void );
522
523/**
524 *  This routine is responsible for transferring control of the
525 *  processor from the executing thread to the heir thread.  As part
526 *  of this process, it is responsible for the following actions:
527 *
528 *     + saving the context of the executing thread
529 *     + restoring the context of the heir thread
530 *     + dispatching any signals for the resulting executing thread
531 */
532void _Thread_Dispatch( void );
533
534/**
535 *  Allocate the requested stack space for the thread.
536 *  return the actual size allocated after any adjustment
537 *  or return zero if the allocation failed.
538 *  Set the Start.stack field to the address of the stack
539 */
540
541size_t _Thread_Stack_Allocate(
542  Thread_Control *the_thread,
543  size_t          stack_size
544);
545
546/**
547 *  Deallocate the Thread's stack.
548 */
549void _Thread_Stack_Free(
550  Thread_Control *the_thread
551);
552
553/**
554 *  This routine initializes the specified the thread.  It allocates
555 *  all memory associated with this thread.  It completes by adding
556 *  the thread to the local object table so operations on this
557 *  thread id are allowed.
558 *
559 *  @note If stack_area is NULL, it is allocated from the workspace.
560 *
561 *  @note If the stack is allocated from the workspace, then it is
562 *        guaranteed to be of at least minimum size.
563 */
564bool _Thread_Initialize(
565  Objects_Information                  *information,
566  Thread_Control                       *the_thread,
567  void                                 *stack_area,
568  size_t                                stack_size,
569  bool                                  is_fp,
570  Priority_Control                      priority,
571  bool                                  is_preemptible,
572  Thread_CPU_budget_algorithms          budget_algorithm,
573  Thread_CPU_budget_algorithm_callout   budget_callout,
574  uint32_t                              isr_level,
575  Objects_Name                          name
576);
577
578/**
579 *  This routine initializes the executable information for a thread
580 *  and makes it ready to execute.  After this routine executes, the
581 *  thread competes with all other threads for CPU time.
582 */
583bool _Thread_Start(
584  Thread_Control            *the_thread,
585  Thread_Start_types         the_prototype,
586  void                      *entry_point,
587  void                      *pointer_argument,
588  Thread_Entry_numeric_type  numeric_argument
589);
590
591/**
592 *  This support routine restarts the specified task in a way that the
593 *  next time this thread executes, it will begin execution at its
594 *  original starting point.
595 *
596 *  TODO:  multiple task arg profiles
597 */
598bool _Thread_Restart(
599  Thread_Control            *the_thread,
600  void                      *pointer_argument,
601  Thread_Entry_numeric_type  numeric_argument
602);
603
604/**
605 *  This routine resets a thread to its initial state but does
606 *  not restart it.
607 */
608void _Thread_Reset(
609  Thread_Control            *the_thread,
610  void                      *pointer_argument,
611  Thread_Entry_numeric_type  numeric_argument
612);
613
614/**
615 *  This routine frees all memory associated with the specified
616 *  thread and removes it from the local object table so no further
617 *  operations on this thread are allowed.
618 */
619void _Thread_Close(
620  Objects_Information  *information,
621  Thread_Control       *the_thread
622);
623
624/**
625 *  This routine removes any set states for the_thread.  It performs
626 *  any necessary scheduling operations including the selection of
627 *  a new heir thread.
628 */
629void _Thread_Ready(
630  Thread_Control *the_thread
631);
632
633/**
634 *  This routine clears the indicated STATES for the_thread.  It performs
635 *  any necessary scheduling operations including the selection of
636 *  a new heir thread.
637 */
638void _Thread_Clear_state(
639  Thread_Control *the_thread,
640  States_Control  state
641);
642
643/**
644 *  This routine sets the indicated states for the_thread.  It performs
645 *  any necessary scheduling operations including the selection of
646 *  a new heir thread.
647 */
648void _Thread_Set_state(
649  Thread_Control *the_thread,
650  States_Control  state
651);
652
653/**
654 *  This routine sets the TRANSIENT state for the_thread.  It performs
655 *  any necessary scheduling operations including the selection of
656 *  a new heir thread.
657 */
658void _Thread_Set_transient(
659  Thread_Control *the_thread
660);
661
662/**
663 *  This routine is invoked as part of processing each clock tick.
664 *  It is responsible for determining if the current thread allows
665 *  timeslicing and, if so, when its timeslice expires.
666 */
667void _Thread_Tickle_timeslice( void );
668
669/**
670 *  This routine initializes the context of the_thread to its
671 *  appropriate starting state.
672 */
673void _Thread_Load_environment(
674  Thread_Control *the_thread
675);
676
677/**
678 *  This routine is the wrapper function for all threads.  It is
679 *  the starting point for all threads.  The user provided thread
680 *  entry point is invoked by this routine.  Operations
681 *  which must be performed immediately before and after the user's
682 *  thread executes are found here.
683 */
684void _Thread_Handler( void );
685
686/**
687 *  This routine is invoked when a thread must be unblocked at the
688 *  end of a time based delay (i.e. wake after or wake when).
689 */
690void _Thread_Delay_ended(
691  Objects_Id  id,
692  void       *ignored
693);
694
695/**
696 *  This routine changes the current priority of the_thread to
697 *  new_priority.  It performs any necessary scheduling operations
698 *  including the selection of a new heir thread.
699 */
700void _Thread_Change_priority (
701  Thread_Control   *the_thread,
702  Priority_Control  new_priority,
703  bool              prepend_it
704);
705
706/**
707 *  This routine updates the priority related fields in the_thread
708 *  control block to indicate the current priority is now new_priority.
709 */
710void _Thread_Set_priority(
711  Thread_Control   *the_thread,
712  Priority_Control  new_priority
713);
714
715/**
716 *  This routine updates the related suspend fields in the_thread
717 *  control block to indicate the current nested level.
718 */
719#define _Thread_Suspend( _the_thread ) \
720        _Thread_Set_state( _the_thread, STATES_SUSPENDED )
721
722/**
723 *  This routine updates the related suspend fields in the_thread
724 *  control block to indicate the current nested level.  A force
725 *  parameter of true will force a resume and clear the suspend count.
726 */
727#define _Thread_Resume( _the_thread ) \
728        _Thread_Clear_state( _the_thread, STATES_SUSPENDED )
729
730#if (CPU_PROVIDES_IDLE_THREAD_BODY == FALSE)
731/**
732 *  This routine is the body of the system idle thread.
733 *
734 *  NOTE: This routine is actually instantiated by confdefs.h when needed.
735 */
736void *_Thread_Idle_body(
737  uintptr_t  ignored
738);
739#endif
740
741/**  This defines the type for a method which operates on a single thread.
742 */
743typedef void (*rtems_per_thread_routine)( Thread_Control * );
744
745/**
746 *  This routine iterates over all threads regardless of API and
747 *  invokes the specified routine.
748 */
749void rtems_iterate_over_all_threads(
750  rtems_per_thread_routine routine
751);
752
753/**
754 *  This function maps thread IDs to thread control
755 *  blocks.  If ID corresponds to a local thread, then it
756 *  returns the_thread control pointer which maps to ID
757 *  and location is set to OBJECTS_LOCAL.  If the thread ID is
758 *  global and resides on a remote node, then location is set
759 *  to OBJECTS_REMOTE, and the_thread is undefined.
760 *  Otherwise, location is set to OBJECTS_ERROR and
761 *  the_thread is undefined.
762 *
763 *  @note  The performance of many RTEMS services depends upon
764 *         the quick execution of the "good object" path in this
765 *         routine.  If there is a possibility of saving a few
766 *         cycles off the execution time, this routine is worth
767 *         further optimization attention.
768 */
769Thread_Control *_Thread_Get (
770  Objects_Id         id,
771  Objects_Locations *location
772);
773
774/**
775 *  @brief Cancel a blocking operation due to ISR
776 *
777 *  This method is used to cancel a blocking operation that was
778 *  satisfied from an ISR while the thread executing was in the
779 *  process of blocking.
780 *
781 *  @param[in] sync_state is the synchronization state
782 *  @param[in] the_thread is the thread whose blocking is canceled
783 *  @param[in] level is the previous ISR disable level
784 *
785 *  @note This is a rare routine in RTEMS.  It is called with
786 *        interrupts disabled and only when an ISR completed
787 *        a blocking condition in process.
788 */
789void _Thread_blocking_operation_Cancel(
790  Thread_blocking_operation_States  sync_state,
791  Thread_Control                   *the_thread,
792  ISR_Level                         level
793);
794
795
796#if defined(RTEMS_SMP)
797
798  /** @brief _Thread_Dispatch_initialization
799   *
800   *  This routine initializes the thread dispatching subsystem.
801   */
802  void _Thread_Dispatch_initialization(void);
803
804  /** @brief _Thread_Dispatch_in_critical_section
805   *
806   * This routine returns true if thread dispatch indicates
807   * that we are in a critical section.
808   */
809  bool _Thread_Dispatch_in_critical_section(void);
810
811  /** @brief _Thread_Dispatch_get_disable_level
812   *
813   * This routine returns value of the the thread dispatch level.
814   */
815  uint32_t _Thread_Dispatch_get_disable_level(void);
816
817  /** @brief _Thread_Dispatch_set_disable_level
818   *
819   * This routine sets thread dispatch level to the
820   * value passed in.
821   */
822  uint32_t _Thread_Dispatch_set_disable_level(uint32_t value);
823
824  /** @brief _Thread_Dispatch_increment_disable_level
825   *
826   * This rountine increments the thread dispatch level
827   */
828  uint32_t _Thread_Dispatch_increment_disable_level(void);
829
830  /** @brief _Thread_Dispatch_decrement_disable_level
831   *
832   * This routine decrements the thread dispatch level.
833   */
834  uint32_t _Thread_Dispatch_decrement_disable_level(void);
835
836#else
837  /*
838   * The _Thread_Dispatch_... functions are in thread.inl
839   */
840#endif
841
842#ifndef __RTEMS_APPLICATION__
843#include <rtems/score/thread.inl>
844#endif
845#if defined(RTEMS_MULTIPROCESSING)
846#include <rtems/score/threadmp.h>
847#endif
848
849#ifdef __cplusplus
850}
851#endif
852
853/**@}*/
854
855#endif
856/* end of include file */
Note: See TracBrowser for help on using the repository browser.