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

5
Last change on this file since c0f1f52 was c0f1f52, checked in by Sebastian Huber <sebastian.huber@…>, on 10/31/16 at 07:08:48

score: Delete Thread_Scheduler_control::node

Update #2556.

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