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

4.11
Last change on this file since a55e305 was a55e305, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 29, 2010 at 5:52:10 PM

2010-07-29 Gedare Bloom <giddyup44@…>

PR 1635/cpukit

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