source: rtems/cpukit/score/include/rtems/score/thread.h @ 3dd67dd1

5
Last change on this file since 3dd67dd1 was 3dd67dd1, checked in by Sebastian Huber <sebastian.huber@…>, on 06/14/17 at 05:29:14

score: Remove rtems_ada_self

This task variable is superfluous since we use thread-local storage now.

Update #2289.

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