source: rtems/cpukit/score/include/rtems/score/thread.h @ 9bfad8c

5
Last change on this file since 9bfad8c was 9bfad8c, checked in by Sebastian Huber <sebastian.huber@…>, on 06/08/16 at 20:22:46

score: Add thread priority to scheduler nodes

The thread priority is manifest in two independent areas. One area is
the user visible thread priority along with a potential thread queue.
The other is the scheduler. Currently, a thread priority update via
_Thread_Change_priority() first updates the user visble thread priority
and the thread queue, then the scheduler is notified if necessary. The
priority is passed to the scheduler via a local variable. A generation
counter ensures that the scheduler discards out-of-date priorities.

This use of a local variable ties the update in these two areas close
together. For later enhancements and the OMIP locking protocol
implementation we need more flexibility. Add a thread priority
information block to Scheduler_Node and synchronize priority value
updates via a sequence lock on SMP configurations.

Update #2556.

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