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

4.104.114.9
Last change on this file since ebfd9ea was ebfd9ea, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 6, 2008 at 4:34:43 PM

2008-06-06 Joel Sherrill <joel.sherrill@…>

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