source: rtems/cpukit/score/include/rtems/score/thread.h @ 351c14d

5
Last change on this file since 351c14d was 351c14d, checked in by Sebastian Huber <sebastian.huber@…>, on 09/27/16 at 09:33:36

score: Add new SMP scheduler helping protocol

Update #2556.

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