source: rtems/cpukit/score/include/rtems/score/thread.h @ 355ee7d

4.115
Last change on this file since 355ee7d was 355ee7d, checked in by Alex Ivanov <alexivanov97@…>, on 11/28/12 at 19:57:31

score misc: Clean up Doxygen #3 (GCI 2012)

This patch is a task from GCI 2012 which improves the Doxygen
comments in the RTEMS source.

http://www.google-melange.com/gci/task/view/google/gci2012/7982215

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