source: rtems/cpukit/score/include/rtems/score/thread.h @ 728a0bd3

4.104.114.84.95
Last change on this file since 728a0bd3 was 728a0bd3, checked in by Ralf Corsepius <ralf.corsepius@…>, on 05/08/07 at 10:43:06

Use size_t for stacksizes.

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