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

5
Last change on this file since d271c3bb was d271c3bb, checked in by Sebastian Huber <sebastian.huber@…>, on 10/31/16 at 12:37:59

rtems: Add rtems_task_iterate()

Update #2423.

  • Property mode set to 100644
File size: 26.0 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
275  /**
276   * @brief The scheduler node of this thread.
277   *
278   * On uni-processor configurations this field is constant after
279   * initialization.
280   *
281   * On SMP configurations the scheduler helping protocol may change this
282   * field.
283   */
284  Scheduler_Node *node;
285
286  /**
287   * @brief The processor assigned by the current scheduler.
288   */
289  struct Per_CPU_Control *cpu;
290
291  /**
292   * @brief Scheduler nodes immediately available to the thread by its home
293   * scheduler instance and due to thread queue ownerships.
294   *
295   * This chain is protected by the thread wait lock.
296   */
297  Chain_Control Wait_nodes;
298#endif
299
300  /**
301   * @brief The scheduler nodes of this thread.
302   *
303   * Each thread has a scheduler node for each scheduler instance.
304   */
305  Scheduler_Node *nodes;
306} Thread_Scheduler_control;
307
308/**
309 *  @brief Union type to hold a pointer to an immutable or a mutable object.
310 *
311 *  The main purpose is to enable passing of pointers to read-only send buffers
312 *  in the message passing subsystem.  This approach is somewhat fragile since
313 *  it prevents the compiler to check if the operations on objects are valid
314 *  with respect to the constant qualifier.  An alternative would be to add a
315 *  third pointer argument for immutable objects, but this would increase the
316 *  structure size.
317 */
318typedef union {
319  void       *mutable_object;
320  const void *immutable_object;
321} Thread_Wait_information_Object_argument_type;
322
323/**
324 * @brief This type is able to contain several flags used to control the wait
325 * class and state of a thread.
326 *
327 * The mutually exclusive wait class flags are
328 * - @ref THREAD_WAIT_CLASS_EVENT,
329 * - @ref THREAD_WAIT_CLASS_SYSTEM_EVENT, and
330 * - @ref THREAD_WAIT_CLASS_OBJECT.
331 *
332 * The mutually exclusive wait state flags are
333 * - @ref THREAD_WAIT_STATE_INTEND_TO_BLOCK,
334 * - @ref THREAD_WAIT_STATE_BLOCKED, and
335 * - @ref THREAD_WAIT_STATE_READY_AGAIN.
336 */
337typedef unsigned int Thread_Wait_flags;
338
339/**
340 *  @brief Information required to manage a thread while it is blocked.
341 *
342 *  This contains the information required to manage a thread while it is
343 *  blocked and to return information to it.
344 */
345typedef struct {
346#if defined(RTEMS_MULTIPROCESSING)
347  /*
348   * @brief This field is the identifier of the remote object this thread is
349   * waiting upon.
350   */
351  Objects_Id            remote_id;
352#endif
353  /** This field is used to return an integer while when blocked. */
354  uint32_t              count;
355  /** This field is for a pointer to a user return argument. */
356  void                 *return_argument;
357  /** This field is for a pointer to a second user return argument. */
358  Thread_Wait_information_Object_argument_type
359                        return_argument_second;
360  /** This field contains any options in effect on this blocking operation. */
361  uint32_t              option;
362  /** This field will contain the return status from a blocking operation.
363   *
364   *  @note The following assumes that all API return codes can be
365   *        treated as an uint32_t.
366   */
367  uint32_t              return_code;
368
369  /**
370   * @brief This field contains several flags used to control the wait class
371   * and state of a thread in case fine-grained locking is used.
372   */
373#if defined(RTEMS_SMP)
374  Atomic_Uint           flags;
375#else
376  Thread_Wait_flags     flags;
377#endif
378
379#if defined(RTEMS_SMP)
380  /**
381   * @brief Thread wait lock control block.
382   *
383   * Parts of the thread wait information are protected by the thread wait
384   * default lock and additionally a thread queue lock in case the thread
385   * is enqueued on a thread queue.
386   *
387   * The thread wait lock mechanism protects the following thread variables
388   *  - POSIX_API_Control::Attributes,
389   *  - Scheduler_Node::Wait,
390   *  - Thread_Control::Wait::Lock::Pending_requests,
391   *  - Thread_Control::Wait::queue, and
392   *  - Thread_Control::Wait::operations.
393   *
394   * @see _Thread_Wait_acquire(), _Thread_Wait_release(), _Thread_Wait_claim(),
395   *   _Thread_Wait_restore_default() and _Thread_Wait_tranquilize().
396   */
397  struct {
398    /**
399     * @brief Thread wait default lock.
400     */
401    ISR_lock_Control Default;
402
403    /**
404     * @brief The pending thread wait lock acquire or tranquilize requests in
405     * case the thread is enqueued on a thread queue.
406     */
407    Chain_Control Pending_requests;
408
409    /**
410     * @brief Tranquilizer gate used by _Thread_Wait_tranquilize().
411     *
412     * This gate is closed by _Thread_Wait_claim().  In case there are no
413     * pending requests during a _Thread_Wait_restore_default(), then this gate
414     * is opened immediately, otherwise it is placed on the pending request
415     * chain and opened by _Thread_Wait_remove_request_locked() as the last
416     * gate on the chain to signal overall request completion.
417     */
418    Thread_queue_Gate Tranquilizer;
419  } Lock;
420
421  /**
422   * @brief Thread queue link provided for use by the thread wait lock owner to
423   * build a thread queue path.
424   */
425  Thread_queue_Link Link;
426#endif
427
428  /**
429   * @brief The current thread queue.
430   *
431   * If this field is NULL the thread is not enqueued on a thread queue.  This
432   * field is protected by the thread wait default lock.
433   *
434   * @see _Thread_Wait_claim().
435   */
436  Thread_queue_Queue *queue;
437
438  /**
439   * @brief The current thread queue operations.
440   *
441   * This field is protected by the thread lock wait default lock.
442   *
443   * @see _Thread_Wait_claim().
444   */
445  const Thread_queue_Operations *operations;
446
447  Thread_queue_Heads *spare_heads;
448}   Thread_Wait_information;
449
450/**
451 * @brief Information required to manage a thread timer.
452 */
453typedef struct {
454  ISR_LOCK_MEMBER( Lock )
455  Watchdog_Header *header;
456  Watchdog_Control Watchdog;
457} Thread_Timer_information;
458
459/**
460 *  The following defines the control block used to manage
461 *  each thread proxy.
462 *
463 *  @note It is critical that proxies and threads have identical
464 *        memory images for the shared part.
465 */
466typedef struct {
467  /** This field is the object management structure for each proxy. */
468  Objects_Control          Object;
469
470  /**
471   * @see Thread_Control::Join_queue
472   */
473  Thread_queue_Control     Join_queue;
474
475  /** This field is the current execution state of this proxy. */
476  States_Control           current_state;
477
478  /**
479   * @brief The base priority of this thread in its home scheduler instance.
480   */
481  Priority_Node            Real_priority;
482
483  /** This field is the number of mutexes currently held by this proxy. */
484  uint32_t                 resource_count;
485
486  /**
487   * @brief Scheduler related control.
488   */
489  Thread_Scheduler_control Scheduler;
490
491  /** This field is the blocking information for this proxy. */
492  Thread_Wait_information  Wait;
493  /** This field is the Watchdog used to manage proxy delays and timeouts. */
494  Thread_Timer_information Timer;
495#if defined(RTEMS_MULTIPROCESSING)
496  /** This field is the received response packet in an MP system. */
497  MP_packet_Prefix        *receive_packet;
498     /****************** end of common block ********************/
499
500  /**
501   * @brief Thread queue callout for _Thread_queue_Enqueue_critical().
502   */
503  Thread_queue_MP_callout  thread_queue_callout;
504
505  /**
506   * @brief This field is used to manage the set of active proxies in the system.
507   */
508  RBTree_Node              Active;
509
510  /**
511   * @brief The scheduler node providing the thread wait nodes used to enqueue
512   * this thread proxy on a thread queue.
513   */
514  Scheduler_Node           Scheduler_node;
515
516  /**
517   * @brief Provide thread queue heads for this thread proxy.
518   *
519   * The actual size of the thread queue heads depends on the application
520   * configuration.  Since thread proxies are never destroyed we can use the
521   * same storage place for the thread queue heads.
522   */
523  Thread_queue_Heads       Thread_queue_heads[ RTEMS_ZERO_LENGTH_ARRAY ];
524#endif
525}   Thread_Proxy_control;
526
527/**
528 *  The following record defines the control block used
529 *  to manage each thread.
530 *
531 *  @note It is critical that proxies and threads have identical
532 *        memory images for the shared part.
533 */
534typedef enum {
535  /** This value is for the Classic RTEMS API. */
536  THREAD_API_RTEMS,
537  /** This value is for the POSIX API. */
538  THREAD_API_POSIX
539}  Thread_APIs;
540
541/** This macro defines the first API which has threads. */
542#define THREAD_API_FIRST THREAD_API_RTEMS
543
544/** This macro defines the last API which has threads. */
545#define THREAD_API_LAST  THREAD_API_POSIX
546
547typedef struct Thread_Action Thread_Action;
548
549/**
550 * @brief Thread action handler.
551 *
552 * The thread action handler will be called with interrupts disabled and a
553 * corresponding lock acquired, e.g. _Thread_State_acquire().  The handler must
554 * release the corresponding lock, e.g. _Thread_State_release().  So, the
555 * corresponding lock may be used to protect private data used by the
556 * particular action.
557 *
558 * Since the action is passed to the handler additional data may be accessed
559 * via RTEMS_CONTAINER_OF().
560 *
561 * @param[in] the_thread The thread performing the action.
562 * @param[in] action The thread action.
563 * @param[in] lock_context The lock context to use for the lock release.
564 */
565typedef void ( *Thread_Action_handler )(
566  Thread_Control   *the_thread,
567  Thread_Action    *action,
568  ISR_lock_Context *lock_context
569);
570
571/**
572 * @brief Thread action.
573 *
574 * Thread actions can be chained together to trigger a set of actions on
575 * particular events like for example a thread post-switch.  Use
576 * _Thread_Action_initialize() to initialize this structure.
577 *
578 * Thread actions are the building block for efficient implementation of
579 * - Classic signals delivery,
580 * - POSIX signals delivery, and
581 * - thread life-cycle changes.
582 *
583 * @see _Thread_Add_post_switch_action() and _Thread_Run_post_switch_actions().
584 */
585struct Thread_Action {
586  Chain_Node            Node;
587  Thread_Action_handler handler;
588};
589
590/**
591 * @brief Per-thread information for POSIX Keys.
592 */
593typedef struct {
594  /**
595   * @brief Key value pairs registered for this thread.
596   */
597  RBTree_Control Key_value_pairs;
598
599  /**
600   * @brief Lock to protect the tree operations.
601   */
602  ISR_LOCK_MEMBER( Lock )
603} Thread_Keys_information;
604
605/**
606 * @brief Control block to manage thread actions.
607 *
608 * Use _Thread_Action_control_initialize() to initialize this structure.
609 */
610typedef struct {
611  Chain_Control Chain;
612} Thread_Action_control;
613
614/**
615 * @brief Thread life states.
616 *
617 * The thread life states are orthogonal to the thread states used for
618 * synchronization primitives and blocking operations.  They reflect the state
619 * changes triggered with thread restart and delete requests.
620 *
621 * The individual state values must be a power of two to allow use of bit
622 * operations to manipulate and evaluate the thread life state.
623 */
624typedef enum {
625  THREAD_LIFE_PROTECTED = 0x1,
626  THREAD_LIFE_RESTARTING = 0x2,
627  THREAD_LIFE_TERMINATING = 0x4,
628  THREAD_LIFE_CHANGE_DEFERRED = 0x8,
629  THREAD_LIFE_DETACHED = 0x10
630} Thread_Life_state;
631
632/**
633 * @brief Thread life control.
634 */
635typedef struct {
636  /**
637   * @brief Thread life action used to react upon thread restart and delete
638   * requests.
639   */
640  Thread_Action      Action;
641
642  /**
643   * @brief The current thread life state.
644   */
645  Thread_Life_state  state;
646
647  /**
648   * @brief The count of pending life change requests.
649   */
650  uint32_t pending_life_change_requests;
651
652#if defined(RTEMS_POSIX_API)
653  /**
654   * @brief The thread exit value.
655   *
656   * It is,
657   * - the value passed to pthread_exit(), or
658   * - PTHREAD_CANCELED in case it is cancelled via pthread_cancel(), or
659   * - NULL.
660   */
661  void *exit_value;
662#endif
663} Thread_Life_control;
664
665typedef struct  {
666  uint32_t      flags;
667  void *        control;
668}Thread_Capture_control;
669
670/**
671 *  This structure defines the Thread Control Block (TCB).
672 *
673 *  Uses a leading underscore in the structure name to allow forward
674 *  declarations in standard header files provided by Newlib and GCC.
675 */
676struct _Thread_Control {
677  /** This field is the object management structure for each thread. */
678  Objects_Control          Object;
679
680  /**
681   * @brief Thread queue for thread join operations and multi-purpose lock.
682   *
683   * The lock of this thread queue is used for various purposes.  It protects
684   * the following fields
685   *
686   * - RTEMS_API_Control::Signal,
687   * - Thread_Control::budget_algorithm,
688   * - Thread_Control::budget_callout,
689   * - Thread_Control::cpu_time_budget,
690   * - Thread_Control::current_state,
691   * - Thread_Control::Post_switch_actions,
692   * - Thread_Control::Scheduler::control, and
693   * - Thread_Control::Scheduler::own_control.
694   *
695   * @see _Thread_State_acquire().
696   */
697  Thread_queue_Control     Join_queue;
698
699  /** This field is the current execution state of this thread. */
700  States_Control           current_state;
701
702  /**
703   * @brief The base priority of this thread in its home scheduler instance.
704   */
705  Priority_Node            Real_priority;
706
707  /** This field is the number of mutexes currently held by this thread. */
708  uint32_t                 resource_count;
709
710  /**
711   * @brief Scheduler related control.
712   */
713  Thread_Scheduler_control Scheduler;
714
715  /** This field is the blocking information for this thread. */
716  Thread_Wait_information  Wait;
717  /** This field is the Watchdog used to manage thread delays and timeouts. */
718  Thread_Timer_information Timer;
719#if defined(RTEMS_MULTIPROCESSING)
720  /** This field is the received response packet in an MP system. */
721  MP_packet_Prefix        *receive_packet;
722#endif
723     /*================= end of common block =================*/
724
725#if defined(RTEMS_SMP) && defined(RTEMS_PROFILING)
726  /**
727   * @brief Potpourri lock statistics.
728   *
729   * These SMP lock statistics are used for all lock objects that lack a
730   * storage space for the statistics.  Examples are lock objects used in
731   * external libraries which are independent of the actual RTEMS build
732   * configuration.
733   */
734  SMP_lock_Stats Potpourri_stats;
735#endif
736
737#if defined(RTEMS_SMP)
738  /**
739   * @brief Resource node to build a dependency tree in case this thread owns
740   * resources or depends on a resource.
741   */
742  Resource_Node            Resource_node;
743#endif
744#if defined(RTEMS_MULTIPROCESSING)
745  /** This field is true if the thread is offered globally */
746  bool                                  is_global;
747#endif
748  /** This field is true if the thread is preemptible. */
749  bool                                  is_preemptible;
750  /** This field is true if the thread uses the floating point unit. */
751  bool                                  is_fp;
752
753#if __RTEMS_ADA__
754  /** This field is the GNAT self context pointer. */
755  void                                 *rtems_ada_self;
756#endif
757  /** This field is the length of the time quantum that this thread is
758   *  allowed to consume.  The algorithm used to manage limits on CPU usage
759   *  is specified by budget_algorithm.
760   */
761  uint32_t                              cpu_time_budget;
762  /** This field is the algorithm used to manage this thread's time
763   *  quantum.  The algorithm may be specified as none which case,
764   *  no limit is in place.
765   */
766  Thread_CPU_budget_algorithms          budget_algorithm;
767  /** This field is the method invoked with the budgeted time is consumed. */
768  Thread_CPU_budget_algorithm_callout   budget_callout;
769  /** This field is the amount of CPU time consumed by this thread
770   *  since it was created.
771   */
772  Timestamp_Control                     cpu_time_used;
773
774  /** This field contains information about the starting state of
775   *  this thread.
776   */
777  Thread_Start_information              Start;
778
779  Thread_Action_control                 Post_switch_actions;
780
781  /** This field contains the context of this thread. */
782  Context_Control                       Registers;
783#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
784  /** This field points to the floating point context for this thread.
785   *  If NULL, the thread is integer only.
786   */
787  Context_Control_fp                   *fp_context;
788#endif
789  /** This field points to the newlib reentrancy structure for this thread. */
790  struct _reent                        *libc_reent;
791  /** This array contains the API extension area pointers. */
792  void                                 *API_Extensions[ THREAD_API_LAST + 1 ];
793
794  /**
795   * @brief The POSIX Keys information.
796   */
797  Thread_Keys_information               Keys;
798
799  /**
800   * @brief Thread life-cycle control.
801   *
802   * Control state changes triggered by thread restart and delete requests.
803   */
804  Thread_Life_control                   Life;
805
806  Thread_Capture_control                Capture;
807
808  /**
809   * @brief LIFO list of POSIX cleanup contexts.
810   */
811  struct _pthread_cleanup_context *last_cleanup_context;
812
813  /**
814   * @brief LIFO list of user extensions iterators.
815   */
816  struct User_extensions_Iterator *last_user_extensions_iterator;
817
818  /**
819   * @brief Variable length array of user extension pointers.
820   *
821   * The length is defined by the application via <rtems/confdefs.h>.
822   */
823  void                                 *extensions[ RTEMS_ZERO_LENGTH_ARRAY ];
824};
825
826#if (CPU_PROVIDES_IDLE_THREAD_BODY == FALSE)
827/**
828 *  This routine is the body of the system idle thread.
829 *
830 *  NOTE: This routine is actually instantiated by confdefs.h when needed.
831 */
832void *_Thread_Idle_body(
833  uintptr_t  ignored
834);
835#endif
836
837typedef void (*rtems_per_thread_routine)( Thread_Control * );
838
839/* Use rtems_task_iterate() instead */
840void rtems_iterate_over_all_threads(
841  rtems_per_thread_routine routine
842) RTEMS_DEPRECATED;
843
844/**
845 * @brief Thread control add-on.
846 */
847typedef struct {
848  /**
849   * @brief Offset of the pointer field in Thread_Control referencing an
850   * application configuration dependent memory area in the thread control
851   * block.
852   */
853  size_t destination_offset;
854
855  /**
856   * @brief Offset relative to the thread control block begin to an application
857   * configuration dependent memory area.
858   */
859  size_t source_offset;
860} Thread_Control_add_on;
861
862/**
863 * @brief Thread control add-ons.
864 *
865 * The thread control block contains fields that point to application
866 * configuration dependent memory areas, like the scheduler information, the
867 * API control blocks, the user extension context table, and the Newlib
868 * re-entrancy support.  Account for these areas in the configuration and
869 * avoid extra workspace allocations for these areas.
870 *
871 * This array is provided via <rtems/confdefs.h>.
872 *
873 * @see _Thread_Control_add_on_count and _Thread_Control_size.
874 */
875extern const Thread_Control_add_on _Thread_Control_add_ons[];
876
877/**
878 * @brief Thread control add-on count.
879 *
880 * Count of entries in _Thread_Control_add_ons.
881 *
882 * This value is provided via <rtems/confdefs.h>.
883 */
884extern const size_t _Thread_Control_add_on_count;
885
886/**
887 * @brief Size of the thread control block of a particular application.
888 *
889 * This value is provided via <rtems/confdefs.h>.
890 *
891 * @see _Thread_Control_add_ons.
892 */
893extern const size_t _Thread_Control_size;
894
895/**@}*/
896
897#ifdef __cplusplus
898}
899#endif
900
901#endif
902/* end of include file */
Note: See TracBrowser for help on using the repository browser.