source: rtems/cpukit/score/include/rtems/score/thread.h @ 0faa9dad

4.115
Last change on this file since 0faa9dad was 0faa9dad, checked in by Joel Sherrill <joel.sherrill@…>, on 11/24/10 at 15:51:28

2010-11-24 Gedare Bloom <giddyup44@…>

PR 1647/cpukit

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