source: rtems/cpukit/score/include/rtems/score/thread.h @ 300f6a48

5
Last change on this file since 300f6a48 was 300f6a48, checked in by Sebastian Huber <sebastian.huber@…>, on 06/22/16 at 15:09:23

score: Rework thread priority management

Add priority nodes which contribute to the overall thread priority.

The actual priority of a thread is now an aggregation of priority nodes.
The thread priority aggregation for the home scheduler instance of a
thread consists of at least one priority node, which is normally the
real priority of the thread. The locking protocols (e.g. priority
ceiling and priority inheritance), rate-monotonic period objects and the
POSIX sporadic server add, change and remove priority nodes.

A thread changes its priority now immediately, e.g. priority changes are
not deferred until the thread releases its last resource.

Replace the _Thread_Change_priority() function with

  • _Thread_Priority_perform_actions(),
  • _Thread_Priority_add(),
  • _Thread_Priority_remove(),
  • _Thread_Priority_change(), and
  • _Thread_Priority_update().

Update #2412.
Update #2556.

  • Property mode set to 100644
File size: 25.9 KB
Line 
1/**
2 *  @file  rtems/score/thread.h
3 *
4 *  @brief Constants and Structures Related with the Thread Control Block
5 *
6 *  This include file contains all constants and structures associated
7 *  with the thread control block.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2014.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  Copyright (c) 2014, 2016 embedded brains GmbH.
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.org/license/LICENSE.
19 */
20
21#ifndef _RTEMS_SCORE_THREAD_H
22#define _RTEMS_SCORE_THREAD_H
23
24#include <rtems/score/atomic.h>
25#include <rtems/score/context.h>
26#if defined(RTEMS_MULTIPROCESSING)
27#include <rtems/score/mppkt.h>
28#endif
29#include <rtems/score/isrlock.h>
30#include <rtems/score/object.h>
31#include <rtems/score/priority.h>
32#include <rtems/score/resource.h>
33#include <rtems/score/schedulernode.h>
34#include <rtems/score/stack.h>
35#include <rtems/score/states.h>
36#include <rtems/score/threadq.h>
37#include <rtems/score/timestamp.h>
38#include <rtems/score/watchdog.h>
39
40#if defined(RTEMS_SMP)
41  #include <rtems/score/cpuset.h>
42#endif
43
44struct _pthread_cleanup_context;
45
46struct Per_CPU_Control;
47
48struct Scheduler_Control;
49
50struct User_extensions_Iterator;
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56/**
57 *  @defgroup ScoreThread Thread Handler
58 *
59 *  @ingroup Score
60 *
61 *  This handler encapsulates functionality related to the management of
62 *  threads.  This includes the creation, deletion, and scheduling of threads.
63 *
64 *  The following variables are maintained as part of the per cpu data
65 *  structure.
66 *
67 *  + Idle thread pointer
68 *  + Executing thread pointer
69 *  + Heir thread pointer
70 */
71/**@{*/
72
73#if defined(RTEMS_POSIX_API)
74  #define RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE
75#endif
76
77/*
78 * With the addition of the Constant Block Scheduler (CBS),
79 * this feature is needed even when POSIX is disabled.
80 */
81#define RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT
82
83#if defined(RTEMS_POSIX_API)
84  #define RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API
85#endif
86
87/*
88 * Only provided for backward compatiblity to not break application
89 * configurations.
90 */
91typedef void *Thread RTEMS_DEPRECATED;
92
93/**
94 *  @brief Type of the numeric argument of a thread entry function with at
95 *  least one numeric argument.
96 *
97 *  This numeric argument type designates an unsigned integer type with the
98 *  property that any valid pointer to void can be converted to this type and
99 *  then converted back to a pointer to void.  The result will compare equal to
100 *  the original pointer.
101 */
102typedef CPU_Uint32ptr Thread_Entry_numeric_type;
103
104/**
105 * @brief Data for idle thread entry.
106 */
107typedef struct {
108  void *( *entry )( uintptr_t argument );
109} Thread_Entry_idle;
110
111/**
112 * @brief Data for thread entry with one numeric argument and no return value.
113 */
114typedef struct {
115  void ( *entry )( Thread_Entry_numeric_type argument );
116  Thread_Entry_numeric_type argument;
117} Thread_Entry_numeric;
118
119/**
120 * @brief Data for thread entry with one pointer argument and a pointer return
121 * value.
122 */
123typedef struct {
124  void *( *entry )( void *argument  );
125  void *argument;
126} Thread_Entry_pointer;
127
128/**
129 * @brief Thread entry information.
130 */
131typedef struct {
132  /**
133   * @brief Thread entry adaptor.
134   *
135   * Calls the corresponding thread entry with the right parameters.
136   *
137   * @param executing The executing thread.
138   */
139  void ( *adaptor )( Thread_Control *executing );
140
141  /**
142   * @brief Thread entry data used by the adaptor to call the thread entry
143   * function with the right parameters.
144   */
145  union {
146    Thread_Entry_idle Idle;
147    Thread_Entry_numeric Numeric;
148    Thread_Entry_pointer Pointer;
149  } Kinds;
150} Thread_Entry_information;
151
152/**
153 *  The following lists the algorithms used to manage the thread cpu budget.
154 *
155 *  Reset Timeslice:   At each context switch, reset the time quantum.
156 *  Exhaust Timeslice: Only reset the quantum once it is consumed.
157 *  Callout:           Execute routine when budget is consumed.
158 */
159typedef enum {
160  THREAD_CPU_BUDGET_ALGORITHM_NONE,
161  THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE,
162  #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE)
163    THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE,
164  #endif
165  #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT)
166    THREAD_CPU_BUDGET_ALGORITHM_CALLOUT
167  #endif
168}  Thread_CPU_budget_algorithms;
169
170/**  This defines thes the entry point for the thread specific timeslice
171 *   budget management algorithm.
172 */
173typedef void (*Thread_CPU_budget_algorithm_callout )( Thread_Control * );
174
175/**
176 *  The following structure contains the information which defines
177 *  the starting state of a thread.
178 */
179typedef struct {
180  /** This field contains the thread entry information. */
181  Thread_Entry_information             Entry;
182  /*-------------- initial execution modes ----------------- */
183  /** This field indicates whether the thread was preemptible when
184    * it started.
185    */
186  bool                                 is_preemptible;
187  /** This field indicates the CPU budget algorith. */
188  Thread_CPU_budget_algorithms         budget_algorithm;
189  /** This field is the routine to invoke when the CPU allotment is
190   *  consumed.
191   */
192  Thread_CPU_budget_algorithm_callout  budget_callout;
193  /** This field is the initial ISR disable level of this thread. */
194  uint32_t                             isr_level;
195  /** This field is the initial priority. */
196  Priority_Control                     initial_priority;
197  #if defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API)
198    /** This field indicates whether the SuperCore allocated the stack. */
199    bool                                 core_allocated_stack;
200  #endif
201  /** This field is the stack information. */
202  Stack_Control                        Initial_stack;
203  #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
204    /** This field is the initial FP context area address. */
205    Context_Control_fp                  *fp_context;
206  #endif
207  /** This field is the initial stack area address. */
208  void                                *stack;
209  /** The thread-local storage (TLS) area */
210  void                                *tls_area;
211} Thread_Start_information;
212
213#if defined(RTEMS_SMP)
214/**
215 * @brief The thread state with respect to the scheduler.
216 */
217typedef enum {
218  /**
219   * @brief This thread is blocked with respect to the scheduler.
220   *
221   * This thread uses no scheduler nodes.
222   */
223  THREAD_SCHEDULER_BLOCKED,
224
225  /**
226   * @brief This thread is scheduled with respect to the scheduler.
227   *
228   * This thread executes using one of its scheduler nodes.  This could be its
229   * own scheduler node or in case it owns resources taking part in the
230   * scheduler helping protocol a scheduler node of another thread.
231   */
232  THREAD_SCHEDULER_SCHEDULED,
233
234  /**
235   * @brief This thread is ready with respect to the scheduler.
236   *
237   * None of the scheduler nodes of this thread is scheduled.
238   */
239  THREAD_SCHEDULER_READY
240} Thread_Scheduler_state;
241#endif
242
243/**
244 * @brief Thread scheduler control.
245 */
246typedef struct {
247#if defined(RTEMS_SMP)
248  /**
249   * @brief The current scheduler state of this thread.
250   */
251  Thread_Scheduler_state state;
252
253  /**
254   * @brief The own scheduler control of this thread.
255   *
256   * This field is constant after initialization.
257   */
258  const struct Scheduler_Control *own_control;
259
260  /**
261   * @brief The scheduler control of this thread.
262   *
263   * The scheduler helping protocol may change this field.
264   */
265  const struct Scheduler_Control *control;
266
267  /**
268   * @brief The own scheduler node of this thread.
269   *
270   * This field is constant after initialization.  It is used by change
271   * priority and ask for help operations.
272   */
273  Scheduler_Node *own_node;
274#endif
275
276  /**
277   * @brief The scheduler node of this thread.
278   *
279   * On uni-processor configurations this field is constant after
280   * initialization.
281   *
282   * On SMP configurations the scheduler helping protocol may change this
283   * field.
284   */
285  Scheduler_Node *node;
286
287#if defined(RTEMS_SMP)
288  /**
289   * @brief The processor assigned by the current scheduler.
290   */
291  struct Per_CPU_Control *cpu;
292#endif
293} Thread_Scheduler_control;
294
295/**
296 *  @brief Union type to hold a pointer to an immutable or a mutable object.
297 *
298 *  The main purpose is to enable passing of pointers to read-only send buffers
299 *  in the message passing subsystem.  This approach is somewhat fragile since
300 *  it prevents the compiler to check if the operations on objects are valid
301 *  with respect to the constant qualifier.  An alternative would be to add a
302 *  third pointer argument for immutable objects, but this would increase the
303 *  structure size.
304 */
305typedef union {
306  void       *mutable_object;
307  const void *immutable_object;
308} Thread_Wait_information_Object_argument_type;
309
310/**
311 * @brief This type is able to contain several flags used to control the wait
312 * class and state of a thread.
313 *
314 * The mutually exclusive wait class flags are
315 * - @ref THREAD_WAIT_CLASS_EVENT,
316 * - @ref THREAD_WAIT_CLASS_SYSTEM_EVENT, and
317 * - @ref THREAD_WAIT_CLASS_OBJECT.
318 *
319 * The mutually exclusive wait state flags are
320 * - @ref THREAD_WAIT_STATE_INTEND_TO_BLOCK,
321 * - @ref THREAD_WAIT_STATE_BLOCKED, and
322 * - @ref THREAD_WAIT_STATE_READY_AGAIN.
323 */
324typedef unsigned int Thread_Wait_flags;
325
326/**
327 *  @brief Information required to manage a thread while it is blocked.
328 *
329 *  This contains the information required to manage a thread while it is
330 *  blocked and to return information to it.
331 */
332typedef struct {
333#if defined(RTEMS_MULTIPROCESSING)
334  /*
335   * @brief This field is the identifier of the remote object this thread is
336   * waiting upon.
337   */
338  Objects_Id            remote_id;
339#endif
340  /** This field is used to return an integer while when blocked. */
341  uint32_t              count;
342  /** This field is for a pointer to a user return argument. */
343  void                 *return_argument;
344  /** This field is for a pointer to a second user return argument. */
345  Thread_Wait_information_Object_argument_type
346                        return_argument_second;
347  /** This field contains any options in effect on this blocking operation. */
348  uint32_t              option;
349  /** This field will contain the return status from a blocking operation.
350   *
351   *  @note The following assumes that all API return codes can be
352   *        treated as an uint32_t.
353   */
354  uint32_t              return_code;
355
356  /**
357   * @brief This field contains several flags used to control the wait class
358   * and state of a thread in case fine-grained locking is used.
359   */
360#if defined(RTEMS_SMP)
361  Atomic_Uint           flags;
362#else
363  Thread_Wait_flags     flags;
364#endif
365
366#if defined(RTEMS_SMP)
367  /**
368   * @brief Thread wait lock control block.
369   *
370   * Parts of the thread wait information are protected by the thread wait
371   * default lock and additionally a thread queue lock in case the thread
372   * is enqueued on a thread queue.
373   *
374   * The thread wait lock mechanism protects the following thread variables
375   *  - POSIX_API_Control::Attributes,
376   *  - Scheduler_Node::Wait,
377   *  - Thread_Control::Wait::Lock::Pending_requests,
378   *  - Thread_Control::Wait::queue, and
379   *  - Thread_Control::Wait::operations.
380   *
381   * @see _Thread_Wait_acquire(), _Thread_Wait_release(), _Thread_Wait_claim(),
382   *   _Thread_Wait_restore_default() and _Thread_Wait_tranquilize().
383   */
384  struct {
385    /**
386     * @brief Thread wait default lock.
387     */
388    ISR_lock_Control Default;
389
390    /**
391     * @brief The pending thread wait lock acquire or tranquilize requests in
392     * case the thread is enqueued on a thread queue.
393     */
394    Chain_Control Pending_requests;
395
396    /**
397     * @brief Tranquilizer gate used by _Thread_Wait_tranquilize().
398     *
399     * This gate is closed by _Thread_Wait_claim().  In case there are no
400     * pending requests during a _Thread_Wait_restore_default(), then this gate
401     * is opened immediately, otherwise it is placed on the pending request
402     * chain and opened by _Thread_Wait_remove_request_locked() as the last
403     * gate on the chain to signal overall request completion.
404     */
405    Thread_queue_Gate Tranquilizer;
406  } Lock;
407
408  /**
409   * @brief Thread queue link provided for use by the thread wait lock owner to
410   * build a thread queue path.
411   */
412  Thread_queue_Link Link;
413#endif
414
415  /**
416   * @brief The current thread queue.
417   *
418   * If this field is NULL the thread is not enqueued on a thread queue.  This
419   * field is protected by the thread wait default lock.
420   *
421   * @see _Thread_Wait_claim().
422   */
423  Thread_queue_Queue *queue;
424
425  /**
426   * @brief The current thread queue operations.
427   *
428   * This field is protected by the thread lock wait default lock.
429   *
430   * @see _Thread_Wait_claim().
431   */
432  const Thread_queue_Operations *operations;
433
434  Thread_queue_Heads *spare_heads;
435}   Thread_Wait_information;
436
437/**
438 * @brief Information required to manage a thread timer.
439 */
440typedef struct {
441  ISR_LOCK_MEMBER( Lock )
442  Watchdog_Header *header;
443  Watchdog_Control Watchdog;
444} Thread_Timer_information;
445
446/**
447 *  The following defines the control block used to manage
448 *  each thread proxy.
449 *
450 *  @note It is critical that proxies and threads have identical
451 *        memory images for the shared part.
452 */
453typedef struct {
454  /** This field is the object management structure for each proxy. */
455  Objects_Control          Object;
456
457  /**
458   * @see Thread_Control::Join_queue
459   */
460  Thread_queue_Control     Join_queue;
461
462  /** This field is the current execution state of this proxy. */
463  States_Control           current_state;
464
465  /**
466   * @brief The base priority of this thread in its home scheduler instance.
467   */
468  Priority_Node            Real_priority;
469
470  /** This field is the number of mutexes currently held by this proxy. */
471  uint32_t                 resource_count;
472
473  /**
474   * @brief Scheduler related control.
475   */
476  Thread_Scheduler_control Scheduler;
477
478  /** This field is the blocking information for this proxy. */
479  Thread_Wait_information  Wait;
480  /** This field is the Watchdog used to manage proxy delays and timeouts. */
481  Thread_Timer_information Timer;
482#if defined(RTEMS_MULTIPROCESSING)
483  /** This field is the received response packet in an MP system. */
484  MP_packet_Prefix        *receive_packet;
485     /****************** end of common block ********************/
486
487  /**
488   * @brief Thread queue callout for _Thread_queue_Enqueue_critical().
489   */
490  Thread_queue_MP_callout  thread_queue_callout;
491
492  /**
493   * @brief This field is used to manage the set of active proxies in the system.
494   */
495  RBTree_Node              Active;
496
497  /**
498   * @brief The scheduler node providing the thread wait nodes used to enqueue
499   * this thread proxy on a thread queue.
500   */
501  Scheduler_Node           Scheduler_node;
502
503  /**
504   * @brief Provide thread queue heads for this thread proxy.
505   *
506   * The actual size of the thread queue heads depends on the application
507   * configuration.  Since thread proxies are never destroyed we can use the
508   * same storage place for the thread queue heads.
509   */
510  Thread_queue_Heads       Thread_queue_heads[ RTEMS_ZERO_LENGTH_ARRAY ];
511#endif
512}   Thread_Proxy_control;
513
514/**
515 *  The following record defines the control block used
516 *  to manage each thread.
517 *
518 *  @note It is critical that proxies and threads have identical
519 *        memory images for the shared part.
520 */
521typedef enum {
522  /** This value is for the Classic RTEMS API. */
523  THREAD_API_RTEMS,
524  /** This value is for the POSIX API. */
525  THREAD_API_POSIX
526}  Thread_APIs;
527
528/** This macro defines the first API which has threads. */
529#define THREAD_API_FIRST THREAD_API_RTEMS
530
531/** This macro defines the last API which has threads. */
532#define THREAD_API_LAST  THREAD_API_POSIX
533
534typedef struct Thread_Action Thread_Action;
535
536/**
537 * @brief Thread action handler.
538 *
539 * The thread action handler will be called with interrupts disabled and a
540 * corresponding lock acquired, e.g. _Thread_State_acquire().  The handler must
541 * release the corresponding lock, e.g. _Thread_State_release().  So, the
542 * corresponding lock may be used to protect private data used by the
543 * particular action.
544 *
545 * Since the action is passed to the handler additional data may be accessed
546 * via RTEMS_CONTAINER_OF().
547 *
548 * @param[in] the_thread The thread performing the action.
549 * @param[in] action The thread action.
550 * @param[in] lock_context The lock context to use for the lock release.
551 */
552typedef void ( *Thread_Action_handler )(
553  Thread_Control   *the_thread,
554  Thread_Action    *action,
555  ISR_lock_Context *lock_context
556);
557
558/**
559 * @brief Thread action.
560 *
561 * Thread actions can be chained together to trigger a set of actions on
562 * particular events like for example a thread post-switch.  Use
563 * _Thread_Action_initialize() to initialize this structure.
564 *
565 * Thread actions are the building block for efficient implementation of
566 * - Classic signals delivery,
567 * - POSIX signals delivery, and
568 * - thread life-cycle changes.
569 *
570 * @see _Thread_Add_post_switch_action() and _Thread_Run_post_switch_actions().
571 */
572struct Thread_Action {
573  Chain_Node            Node;
574  Thread_Action_handler handler;
575};
576
577/**
578 * @brief Per-thread information for POSIX Keys.
579 */
580typedef struct {
581  /**
582   * @brief Key value pairs registered for this thread.
583   */
584  RBTree_Control Key_value_pairs;
585
586  /**
587   * @brief Lock to protect the tree operations.
588   */
589  ISR_LOCK_MEMBER( Lock )
590} Thread_Keys_information;
591
592/**
593 * @brief Control block to manage thread actions.
594 *
595 * Use _Thread_Action_control_initialize() to initialize this structure.
596 */
597typedef struct {
598  Chain_Control Chain;
599} Thread_Action_control;
600
601/**
602 * @brief Thread life states.
603 *
604 * The thread life states are orthogonal to the thread states used for
605 * synchronization primitives and blocking operations.  They reflect the state
606 * changes triggered with thread restart and delete requests.
607 *
608 * The individual state values must be a power of two to allow use of bit
609 * operations to manipulate and evaluate the thread life state.
610 */
611typedef enum {
612  THREAD_LIFE_PROTECTED = 0x1,
613  THREAD_LIFE_RESTARTING = 0x2,
614  THREAD_LIFE_TERMINATING = 0x4,
615  THREAD_LIFE_CHANGE_DEFERRED = 0x8,
616  THREAD_LIFE_DETACHED = 0x10
617} Thread_Life_state;
618
619/**
620 * @brief Thread life control.
621 */
622typedef struct {
623  /**
624   * @brief Thread life action used to react upon thread restart and delete
625   * requests.
626   */
627  Thread_Action      Action;
628
629  /**
630   * @brief The current thread life state.
631   */
632  Thread_Life_state  state;
633
634  /**
635   * @brief The count of pending life change requests.
636   */
637  uint32_t pending_life_change_requests;
638
639#if defined(RTEMS_POSIX_API)
640  /**
641   * @brief The thread exit value.
642   *
643   * It is,
644   * - the value passed to pthread_exit(), or
645   * - PTHREAD_CANCELED in case it is cancelled via pthread_cancel(), or
646   * - NULL.
647   */
648  void *exit_value;
649#endif
650} Thread_Life_control;
651
652typedef struct  {
653  uint32_t      flags;
654  void *        control;
655}Thread_Capture_control;
656
657/**
658 *  This structure defines the Thread Control Block (TCB).
659 *
660 *  Uses a leading underscore in the structure name to allow forward
661 *  declarations in standard header files provided by Newlib and GCC.
662 */
663struct _Thread_Control {
664  /** This field is the object management structure for each thread. */
665  Objects_Control          Object;
666
667  /**
668   * @brief Thread queue for thread join operations and multi-purpose lock.
669   *
670   * The lock of this thread queue is used for various purposes.  It protects
671   * the following fields
672   *
673   * - RTEMS_API_Control::Signal,
674   * - Thread_Control::budget_algorithm,
675   * - Thread_Control::budget_callout,
676   * - Thread_Control::cpu_time_budget,
677   * - Thread_Control::current_state,
678   * - Thread_Control::Post_switch_actions,
679   * - Thread_Control::Scheduler::control, and
680   * - Thread_Control::Scheduler::own_control.
681   *
682   * @see _Thread_State_acquire().
683   */
684  Thread_queue_Control     Join_queue;
685
686  /** This field is the current execution state of this thread. */
687  States_Control           current_state;
688
689  /**
690   * @brief The base priority of this thread in its home scheduler instance.
691   */
692  Priority_Node            Real_priority;
693
694  /** This field is the number of mutexes currently held by this thread. */
695  uint32_t                 resource_count;
696
697  /**
698   * @brief Scheduler related control.
699   */
700  Thread_Scheduler_control Scheduler;
701
702  /** This field is the blocking information for this thread. */
703  Thread_Wait_information  Wait;
704  /** This field is the Watchdog used to manage thread delays and timeouts. */
705  Thread_Timer_information Timer;
706#if defined(RTEMS_MULTIPROCESSING)
707  /** This field is the received response packet in an MP system. */
708  MP_packet_Prefix        *receive_packet;
709#endif
710     /*================= end of common block =================*/
711
712#if defined(RTEMS_SMP) && defined(RTEMS_PROFILING)
713  /**
714   * @brief Potpourri lock statistics.
715   *
716   * These SMP lock statistics are used for all lock objects that lack a
717   * storage space for the statistics.  Examples are lock objects used in
718   * external libraries which are independent of the actual RTEMS build
719   * configuration.
720   */
721  SMP_lock_Stats Potpourri_stats;
722#endif
723
724#if defined(RTEMS_SMP)
725  /**
726   * @brief Resource node to build a dependency tree in case this thread owns
727   * resources or depends on a resource.
728   */
729  Resource_Node            Resource_node;
730#endif
731#if defined(RTEMS_MULTIPROCESSING)
732  /** This field is true if the thread is offered globally */
733  bool                                  is_global;
734#endif
735  /** This field is true if the thread is preemptible. */
736  bool                                  is_preemptible;
737  /** This field is true if the thread uses the floating point unit. */
738  bool                                  is_fp;
739
740#if __RTEMS_ADA__
741  /** This field is the GNAT self context pointer. */
742  void                                 *rtems_ada_self;
743#endif
744  /** This field is the length of the time quantum that this thread is
745   *  allowed to consume.  The algorithm used to manage limits on CPU usage
746   *  is specified by budget_algorithm.
747   */
748  uint32_t                              cpu_time_budget;
749  /** This field is the algorithm used to manage this thread's time
750   *  quantum.  The algorithm may be specified as none which case,
751   *  no limit is in place.
752   */
753  Thread_CPU_budget_algorithms          budget_algorithm;
754  /** This field is the method invoked with the budgeted time is consumed. */
755  Thread_CPU_budget_algorithm_callout   budget_callout;
756  /** This field is the amount of CPU time consumed by this thread
757   *  since it was created.
758   */
759  Timestamp_Control                     cpu_time_used;
760
761  /** This field contains information about the starting state of
762   *  this thread.
763   */
764  Thread_Start_information              Start;
765
766  Thread_Action_control                 Post_switch_actions;
767
768  /** This field contains the context of this thread. */
769  Context_Control                       Registers;
770#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
771  /** This field points to the floating point context for this thread.
772   *  If NULL, the thread is integer only.
773   */
774  Context_Control_fp                   *fp_context;
775#endif
776  /** This field points to the newlib reentrancy structure for this thread. */
777  struct _reent                        *libc_reent;
778  /** This array contains the API extension area pointers. */
779  void                                 *API_Extensions[ THREAD_API_LAST + 1 ];
780
781  /**
782   * @brief The POSIX Keys information.
783   */
784  Thread_Keys_information               Keys;
785
786  /**
787   * @brief Thread life-cycle control.
788   *
789   * Control state changes triggered by thread restart and delete requests.
790   */
791  Thread_Life_control                   Life;
792
793  Thread_Capture_control                Capture;
794
795  /**
796   * @brief LIFO list of POSIX cleanup contexts.
797   */
798  struct _pthread_cleanup_context *last_cleanup_context;
799
800  /**
801   * @brief LIFO list of user extensions iterators.
802   */
803  struct User_extensions_Iterator *last_user_extensions_iterator;
804
805  /**
806   * @brief Variable length array of user extension pointers.
807   *
808   * The length is defined by the application via <rtems/confdefs.h>.
809   */
810  void                                 *extensions[ RTEMS_ZERO_LENGTH_ARRAY ];
811};
812
813#if (CPU_PROVIDES_IDLE_THREAD_BODY == FALSE)
814/**
815 *  This routine is the body of the system idle thread.
816 *
817 *  NOTE: This routine is actually instantiated by confdefs.h when needed.
818 */
819void *_Thread_Idle_body(
820  uintptr_t  ignored
821);
822#endif
823
824/**  This defines the type for a method which operates on a single thread.
825 */
826typedef void (*rtems_per_thread_routine)( Thread_Control * );
827
828/**
829 *  @brief Iterates over all threads.
830 *  This routine iterates over all threads regardless of API and
831 *  invokes the specified routine.
832 */
833void rtems_iterate_over_all_threads(
834  rtems_per_thread_routine routine
835);
836
837/**
838 * @brief Thread control add-on.
839 */
840typedef struct {
841  /**
842   * @brief Offset of the pointer field in Thread_Control referencing an
843   * application configuration dependent memory area in the thread control
844   * block.
845   */
846  size_t destination_offset;
847
848  /**
849   * @brief Offset relative to the thread control block begin to an application
850   * configuration dependent memory area.
851   */
852  size_t source_offset;
853} Thread_Control_add_on;
854
855/**
856 * @brief Thread control add-ons.
857 *
858 * The thread control block contains fields that point to application
859 * configuration dependent memory areas, like the scheduler information, the
860 * API control blocks, the user extension context table, and the Newlib
861 * re-entrancy support.  Account for these areas in the configuration and
862 * avoid extra workspace allocations for these areas.
863 *
864 * This array is provided via <rtems/confdefs.h>.
865 *
866 * @see _Thread_Control_add_on_count and _Thread_Control_size.
867 */
868extern const Thread_Control_add_on _Thread_Control_add_ons[];
869
870/**
871 * @brief Thread control add-on count.
872 *
873 * Count of entries in _Thread_Control_add_ons.
874 *
875 * This value is provided via <rtems/confdefs.h>.
876 */
877extern const size_t _Thread_Control_add_on_count;
878
879/**
880 * @brief Size of the thread control block of a particular application.
881 *
882 * This value is provided via <rtems/confdefs.h>.
883 *
884 * @see _Thread_Control_add_ons.
885 */
886extern const size_t _Thread_Control_size;
887
888/**@}*/
889
890#ifdef __cplusplus
891}
892#endif
893
894#endif
895/* end of include file */
Note: See TracBrowser for help on using the repository browser.