source: rtems/cpukit/score/include/rtems/score/thread.h @ 64ba1a96

5
Last change on this file since 64ba1a96 was 64ba1a96, checked in by Sebastian Huber <sebastian.huber@…>, on 11/08/17 at 14:29:14

posix: Change created_with_explicit_scheduler

Remove POSIX_API_Control::created_with_explicit_scheduler. Add
Thread_Control::was_created_with_inherited_scheduler. This fixes also
pthread_getattr_np() for Classic tasks.

Update #2514.

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