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

4.115
Last change on this file since d7c3883 was d7c3883, checked in by Jennifer Averett <Jennifer.Averett@…>, on 04/21/11 at 19:05:15

2011-04-21 Jennifer Averett <Jennifer.Averett@…

PR 1777/cpukit

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