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

4.115
Last change on this file since d63f1c9 was d63f1c9, checked in by Sebastian Huber <sebastian.huber@…>, on 10/17/11 at 15:54:41

2011-10-17 Sebastian Huber <sebastian.huber@…>

PR 1938/cpukit

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