source: rtems/cpukit/score/include/rtems/score/thread.h @ 97312fcc

5
Last change on this file since 97312fcc was 97312fcc, checked in by Sebastian Huber <sebastian.huber@…>, on 04/05/16 at 12:36:30

score: Delete Thread_Wait_information::id

This field was only by the monitor in non-multiprocessing
configurations. Add new field Thread_Wait_information::remote_id in
multiprocessing configurations and use it for the remote procedure call
thread queue.

Add _Thread_Wait_get_id() to obtain the object identifier for debug and
system information tools. Ensure the object layout via static asserts.
Add test cases to sptests/spthreadq01.

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