source: rtems/cpukit/score/include/rtems/score/thread.h @ 46d3c6d8

4.115
Last change on this file since 46d3c6d8 was 46d3c6d8, checked in by Gedare Bloom <gedare@…>, on Mar 16, 2015 at 8:15:55 PM

cpukit: add and use CPU_Uint32ptr type

  • Property mode set to 100644
File size: 24.9 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/object.h>
30#include <rtems/score/percpu.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/watchdog.h>
37
38#if defined(RTEMS_SMP)
39  #include <rtems/score/cpuset.h>
40#endif
41
42struct Scheduler_Control;
43
44struct Scheduler_Node;
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/**
51 *  @defgroup ScoreThread Thread Handler
52 *
53 *  @ingroup Score
54 *
55 *  This handler encapsulates functionality related to the management of
56 *  threads.  This includes the creation, deletion, and scheduling of threads.
57 *
58 *  The following variables are maintained as part of the per cpu data
59 *  structure.
60 *
61 *  + Idle thread pointer
62 *  + Executing thread pointer
63 *  + Heir thread pointer
64 */
65/**@{*/
66
67#if defined(RTEMS_POSIX_API)
68  #define RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE
69#endif
70
71/*
72 * With the addition of the Constant Block Scheduler (CBS),
73 * this feature is needed even when POSIX is disabled.
74 */
75#define RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT
76
77#if defined(RTEMS_POSIX_API)
78  #define RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API
79#endif
80
81/*
82 *  The user can define this at configure time and go back to ticks
83 *  resolution.
84 */
85#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
86  #include <rtems/score/timestamp.h>
87
88  typedef Timestamp_Control Thread_CPU_usage_t;
89#else
90  typedef uint32_t Thread_CPU_usage_t;
91#endif
92
93/**
94 *  The following defines the "return type" of a thread.
95 *
96 *  @note  This cannot always be right.  Some APIs have void
97 *         tasks/threads, others return pointers, others may
98 *         return a numeric value.  Hopefully a pointer is
99 *         always at least as big as an uint32_t  . :)
100 */
101typedef void *Thread;
102
103/**
104 *  @brief Type of the numeric argument of a thread entry function with at
105 *  least one numeric argument.
106 *
107 *  This numeric argument type designates an unsigned integer type with the
108 *  property that any valid pointer to void can be converted to this type and
109 *  then converted back to a pointer to void.  The result will compare equal to
110 *  the original pointer.
111 */
112typedef CPU_Uint32ptr Thread_Entry_numeric_type;
113
114/**
115 *  The following defines the ways in which the entry point for a
116 *  thread can be invoked.  Basically, it can be passed any
117 *  combination/permutation of a pointer and an uint32_t   value.
118 *
119 *  @note For now, we are ignoring the return type.
120 */
121typedef enum {
122  THREAD_START_NUMERIC,
123  THREAD_START_POINTER,
124  #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
125    THREAD_START_BOTH_POINTER_FIRST,
126    THREAD_START_BOTH_NUMERIC_FIRST
127  #endif
128} Thread_Start_types;
129
130/** This type corresponds to a very simple style thread entry point. */
131typedef Thread ( *Thread_Entry )( void );   /* basic type */
132
133/** This type corresponds to a thread entry point which takes a single
134 *  unsigned thirty-two bit integer as an argument.
135 */
136typedef Thread ( *Thread_Entry_numeric )( Thread_Entry_numeric_type );
137
138/** This type corresponds to a thread entry point which takes a single
139 *  untyped pointer as an argument.
140 */
141typedef Thread ( *Thread_Entry_pointer )( void * );
142
143/** This type corresponds to a thread entry point which takes a single
144 *  untyped pointer and an unsigned thirty-two bit integer as arguments.
145 */
146typedef Thread ( *Thread_Entry_both_pointer_first )( void *, Thread_Entry_numeric_type );
147
148/** This type corresponds to a thread entry point which takes a single
149 *  unsigned thirty-two bit integer and an untyped pointer and an
150 *  as arguments.
151 */
152typedef Thread ( *Thread_Entry_both_numeric_first )( Thread_Entry_numeric_type, void * );
153
154/**
155 *  The following lists the algorithms used to manage the thread cpu budget.
156 *
157 *  Reset Timeslice:   At each context switch, reset the time quantum.
158 *  Exhaust Timeslice: Only reset the quantum once it is consumed.
159 *  Callout:           Execute routine when budget is consumed.
160 */
161typedef enum {
162  THREAD_CPU_BUDGET_ALGORITHM_NONE,
163  THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE,
164  #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE)
165    THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE,
166  #endif
167  #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT)
168    THREAD_CPU_BUDGET_ALGORITHM_CALLOUT
169  #endif
170}  Thread_CPU_budget_algorithms;
171
172/**  This defines thes the entry point for the thread specific timeslice
173 *   budget management algorithm.
174 */
175typedef void (*Thread_CPU_budget_algorithm_callout )( Thread_Control * );
176
177#if !defined(RTEMS_SMP)
178/**
179 *  @brief Forward reference to the per task variable structure..
180 *
181 *  Forward reference to the per task variable structure.
182 */
183struct rtems_task_variable_tt;
184
185/**
186 *  @brief Internal structure used to manager per task variables.
187 *
188 *  This is the internal structure used to manager per Task Variables.
189 */
190typedef struct {
191  /** This field points to the next per task variable for this task. */
192  struct rtems_task_variable_tt  *next;
193  /** This field points to the physical memory location of this per
194   *  task variable.
195   */
196  void                          **ptr;
197  /** This field is to the global value for this per task variable. */
198  void                           *gval;
199  /** This field is to this thread's value for this per task variable. */
200  void                           *tval;
201  /** This field points to the destructor for this per task variable. */
202  void                          (*dtor)(void *);
203} rtems_task_variable_t;
204#endif
205
206/**
207 *  The following structure contains the information which defines
208 *  the starting state of a thread.
209 */
210typedef struct {
211  /** This field is the starting address for the thread. */
212  Thread_Entry                         entry_point;
213  /** This field indicates the how task is invoked. */
214  Thread_Start_types                   prototype;
215  /** This field is the pointer argument passed at thread start. */
216  void                                *pointer_argument;
217  /** This field is the numeric argument passed at thread start. */
218  Thread_Entry_numeric_type            numeric_argument;
219  /*-------------- initial execution modes ----------------- */
220  /** This field indicates whether the thread was preemptible when
221    * it started.
222    */
223  bool                                 is_preemptible;
224  /** This field indicates the CPU budget algorith. */
225  Thread_CPU_budget_algorithms         budget_algorithm;
226  /** This field is the routine to invoke when the CPU allotment is
227   *  consumed.
228   */
229  Thread_CPU_budget_algorithm_callout  budget_callout;
230  /** This field is the initial ISR disable level of this thread. */
231  uint32_t                             isr_level;
232  /** This field is the initial priority. */
233  Priority_Control                     initial_priority;
234  #if defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API)
235    /** This field indicates whether the SuperCore allocated the stack. */
236    bool                                 core_allocated_stack;
237  #endif
238  /** This field is the stack information. */
239  Stack_Control                        Initial_stack;
240  #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
241    /** This field is the initial FP context area address. */
242    Context_Control_fp                  *fp_context;
243  #endif
244  /** This field is the initial stack area address. */
245  void                                *stack;
246  /** The thread-local storage (TLS) area */
247  void                                *tls_area;
248} Thread_Start_information;
249
250/**
251 *  @brief Union type to hold a pointer to an immutable or a mutable object.
252 *
253 *  The main purpose is to enable passing of pointers to read-only send buffers
254 *  in the message passing subsystem.  This approach is somewhat fragile since
255 *  it prevents the compiler to check if the operations on objects are valid
256 *  with respect to the constant qualifier.  An alternative would be to add a
257 *  third pointer argument for immutable objects, but this would increase the
258 *  structure size.
259 */
260typedef union {
261  void       *mutable_object;
262  const void *immutable_object;
263} Thread_Wait_information_Object_argument_type;
264
265/**
266 * @brief This type is able to contain several flags used to control the wait
267 * class and state of a thread.
268 *
269 * The mutually exclusive wait class flags are
270 * - @ref THREAD_WAIT_CLASS_EVENT,
271 * - @ref THREAD_WAIT_CLASS_SYSTEM_EVENT, and
272 * - @ref THREAD_WAIT_CLASS_OBJECT.
273 *
274 * The mutually exclusive wait state flags are
275 * - @ref THREAD_WAIT_STATE_INTEND_TO_BLOCK,
276 * - @ref THREAD_WAIT_STATE_BLOCKED,
277 * - @ref THREAD_WAIT_STATE_SATISFIED,
278 * - @ref THREAD_WAIT_STATE_TIMEOUT,
279 * - @ref THREAD_WAIT_STATE_INTERRUPT_SATISFIED, and
280 * - @ref THREAD_WAIT_STATE_INTERRUPT_TIMEOUT,
281 */
282typedef unsigned int Thread_Wait_flags;
283
284/**
285 *  @brief Information required to manage a thread while it is blocked.
286 *
287 *  This contains the information required to manage a thread while it is
288 *  blocked and to return information to it.
289 */
290typedef struct {
291  /** This field is the Id of the object this thread is waiting upon. */
292  Objects_Id            id;
293  /** This field is used to return an integer while when blocked. */
294  uint32_t              count;
295  /** This field is for a pointer to a user return argument. */
296  void                 *return_argument;
297  /** This field is for a pointer to a second user return argument. */
298  Thread_Wait_information_Object_argument_type
299                        return_argument_second;
300  /** This field contains any options in effect on this blocking operation. */
301  uint32_t              option;
302  /** This field will contain the return status from a blocking operation.
303   *
304   *  @note The following assumes that all API return codes can be
305   *        treated as an uint32_t.
306   */
307  uint32_t              return_code;
308
309  /** This field points to the thread queue on which this thread is blocked. */
310  Thread_queue_Control *queue;
311
312  /**
313   * @brief This field contains several flags used to control the wait class
314   * and state of a thread in case fine-grained locking is used.
315   */
316#if defined(RTEMS_SMP)
317  Atomic_Uint           flags;
318#else
319  Thread_Wait_flags     flags;
320#endif
321}   Thread_Wait_information;
322
323/**
324 *  The following defines the control block used to manage
325 *  each thread proxy.
326 *
327 *  @note It is critical that proxies and threads have identical
328 *        memory images for the shared part.
329 */
330typedef struct {
331  /** This field is the object management structure for each proxy. */
332  Objects_Control          Object;
333  /** This field is used to enqueue the thread on RBTrees. */
334  RBTree_Node              RBNode;
335  /** This field is the current execution state of this proxy. */
336  States_Control           current_state;
337  /** This field is the current priority state of this proxy. */
338  Priority_Control         current_priority;
339  /** This field is the base priority of this proxy. */
340  Priority_Control         real_priority;
341  /** This field is the number of mutexes currently held by this proxy. */
342  uint32_t                 resource_count;
343
344  /** This field is the blocking information for this proxy. */
345  Thread_Wait_information  Wait;
346  /** This field is the Watchdog used to manage proxy delays and timeouts. */
347  Watchdog_Control         Timer;
348#if defined(RTEMS_MULTIPROCESSING)
349  /** This field is the received response packet in an MP system. */
350  MP_packet_Prefix        *receive_packet;
351#endif
352     /****************** end of common block ********************/
353  /** This field is used to manage the set of proxies in the system. */
354  Chain_Node               Active;
355}   Thread_Proxy_control;
356
357/**
358 *  The following record defines the control block used
359 *  to manage each thread.
360 *
361 *  @note It is critical that proxies and threads have identical
362 *        memory images for the shared part.
363 */
364typedef enum {
365  /** This value is for the Classic RTEMS API. */
366  THREAD_API_RTEMS,
367  /** This value is for the POSIX API. */
368  THREAD_API_POSIX
369}  Thread_APIs;
370
371/** This macro defines the first API which has threads. */
372#define THREAD_API_FIRST THREAD_API_RTEMS
373
374/** This macro defines the last API which has threads. */
375#define THREAD_API_LAST  THREAD_API_POSIX
376
377typedef struct Thread_Action Thread_Action;
378
379/**
380 * @brief Thread action handler.
381 *
382 * The thread action handler will be called with interrupts disabled and the
383 * thread action lock acquired.  The handler must release the thread action
384 * lock with _Thread_Action_release_and_ISR_enable().  So the thread action
385 * lock can be used to protect private data fields of the particular action.
386 *
387 * Since the action is passed to the handler private data fields can be added
388 * below the common thread action fields.
389 *
390 * @param[in] thread The thread performing the action.
391 * @param[in] action The thread action.
392 * @param[in] cpu The processor of the thread.
393 * @param[in] level The ISR level for _Thread_Action_release_and_ISR_enable().
394 */
395typedef void ( *Thread_Action_handler )(
396  Thread_Control  *thread,
397  Thread_Action   *action,
398  Per_CPU_Control *cpu,
399  ISR_Level        level
400);
401
402/**
403 * @brief Thread action.
404 *
405 * Thread actions can be chained together to trigger a set of actions on
406 * particular events like for example a thread post-switch.  Use
407 * _Thread_Action_initialize() to initialize this structure.
408 *
409 * Thread actions are the building block for efficient implementation of
410 * - Classic signals delivery,
411 * - POSIX signals delivery,
412 * - thread restart notification,
413 * - thread delete notification,
414 * - forced thread migration on SMP configurations, and
415 * - the Multiprocessor Resource Sharing Protocol (MrsP).
416 *
417 * @see _Thread_Run_post_switch_actions().
418 */
419struct Thread_Action {
420  Chain_Node            Node;
421  Thread_Action_handler handler;
422};
423
424/**
425 * @brief Control block to manage thread actions.
426 *
427 * Use _Thread_Action_control_initialize() to initialize this structure.
428 */
429typedef struct {
430  Chain_Control Chain;
431} Thread_Action_control;
432
433/**
434 * @brief Thread life states.
435 *
436 * The thread life states are orthogonal to the thread states used for
437 * synchronization primitives and blocking operations.  They reflect the state
438 * changes triggered with thread restart and delete requests.
439 */
440typedef enum {
441  THREAD_LIFE_NORMAL = 0x0,
442  THREAD_LIFE_PROTECTED = 0x1,
443  THREAD_LIFE_RESTARTING = 0x2,
444  THREAD_LIFE_PROTECTED_RESTARTING = 0x3,
445  THREAD_LIFE_TERMINATING = 0x4,
446  THREAD_LIFE_PROTECTED_TERMINATING = 0x5,
447  THREAD_LIFE_RESTARTING_TERMINATING = 0x6,
448  THREAD_LIFE_PROTECTED_RESTARTING_TERMINATING = 0x7
449} Thread_Life_state;
450
451/**
452 * @brief Thread life control.
453 */
454typedef struct {
455  /**
456   * @brief Thread life action used to react upon thread restart and delete
457   * requests.
458   */
459  Thread_Action      Action;
460
461  /**
462   * @brief The current thread life state.
463   */
464  Thread_Life_state  state;
465
466  /**
467   * @brief The terminator thread of this thread.
468   *
469   * In case the thread is terminated and another thread (the terminator) waits
470   * for the actual termination completion, then this field references the
471   * terminator thread.
472   */
473  Thread_Control    *terminator;
474} Thread_Life_control;
475
476#if defined(RTEMS_SMP)
477/**
478 * @brief The thread state with respect to the scheduler.
479 */
480typedef enum {
481  /**
482   * @brief This thread is blocked with respect to the scheduler.
483   *
484   * This thread uses no scheduler nodes.
485   */
486  THREAD_SCHEDULER_BLOCKED,
487
488  /**
489   * @brief This thread is scheduled with respect to the scheduler.
490   *
491   * This thread executes using one of its scheduler nodes.  This could be its
492   * own scheduler node or in case it owns resources taking part in the
493   * scheduler helping protocol a scheduler node of another thread.
494   */
495  THREAD_SCHEDULER_SCHEDULED,
496
497  /**
498   * @brief This thread is ready with respect to the scheduler.
499   *
500   * None of the scheduler nodes of this thread is scheduled.
501   */
502  THREAD_SCHEDULER_READY
503} Thread_Scheduler_state;
504#endif
505
506/**
507 * @brief Thread scheduler control.
508 */
509typedef struct {
510#if defined(RTEMS_SMP)
511  /**
512   * @brief The current scheduler state of this thread.
513   */
514  Thread_Scheduler_state state;
515
516  /**
517   * @brief The own scheduler control of this thread.
518   *
519   * This field is constant after initialization.
520   */
521  const struct Scheduler_Control *own_control;
522
523  /**
524   * @brief The scheduler control of this thread.
525   *
526   * The scheduler helping protocol may change this field.
527   */
528  const struct Scheduler_Control *control;
529
530  /**
531   * @brief The own scheduler node of this thread.
532   *
533   * This field is constant after initialization.  It is used by change
534   * priority and ask for help operations.
535   */
536  struct Scheduler_Node *own_node;
537#endif
538
539  /**
540   * @brief The scheduler node of this thread.
541   *
542   * On uni-processor configurations this field is constant after
543   * initialization.
544   *
545   * On SMP configurations the scheduler helping protocol may change this
546   * field.
547   */
548  struct Scheduler_Node *node;
549
550#if defined(RTEMS_SMP)
551  /**
552   * @brief The processor assigned by the current scheduler.
553   */
554  Per_CPU_Control *cpu;
555
556#if defined(RTEMS_DEBUG)
557  /**
558   * @brief The processor on which this thread executed the last time or is
559   * executing.
560   */
561  Per_CPU_Control *debug_real_cpu;
562#endif
563#endif
564} Thread_Scheduler_control;
565
566typedef struct  {
567  uint32_t      flags;
568  void *        control;
569}Thread_Capture_control;
570
571/**
572 *  This structure defines the Thread Control Block (TCB).
573 */
574struct Thread_Control_struct {
575  /** This field is the object management structure for each thread. */
576  Objects_Control          Object;
577  /** This field is used to enqueue the thread on RBTrees. */
578  RBTree_Node              RBNode;
579  /** This field is the current execution state of this thread. */
580  States_Control           current_state;
581  /** This field is the current priority state of this thread. */
582  Priority_Control         current_priority;
583  /** This field is the base priority of this thread. */
584  Priority_Control         real_priority;
585  /** This field is the number of mutexes currently held by this thread. */
586  uint32_t                 resource_count;
587  /** This field is the blocking information for this thread. */
588  Thread_Wait_information  Wait;
589  /** This field is the Watchdog used to manage thread delays and timeouts. */
590  Watchdog_Control         Timer;
591#if defined(RTEMS_MULTIPROCESSING)
592  /** This field is the received response packet in an MP system. */
593  MP_packet_Prefix        *receive_packet;
594#endif
595#ifdef __RTEMS_STRICT_ORDER_MUTEX__
596  /** This field is the head of queue of priority inheritance mutex
597   *  held by the thread.
598   */
599  Chain_Control            lock_mutex;
600#endif
601#if defined(RTEMS_SMP)
602  /**
603   * @brief Resource node to build a dependency tree in case this thread owns
604   * resources or depends on a resource.
605   */
606  Resource_Node            Resource_node;
607#endif
608     /*================= end of common block =================*/
609#if defined(RTEMS_MULTIPROCESSING)
610  /** This field is true if the thread is offered globally */
611  bool                                  is_global;
612#endif
613  /** This field is true if the thread is preemptible. */
614  bool                                  is_preemptible;
615
616  /**
617   * @brief Scheduler related control.
618   */
619  Thread_Scheduler_control              Scheduler;
620
621#if __RTEMS_ADA__
622  /** This field is the GNAT self context pointer. */
623  void                                 *rtems_ada_self;
624#endif
625  /** This field is the length of the time quantum that this thread is
626   *  allowed to consume.  The algorithm used to manage limits on CPU usage
627   *  is specified by budget_algorithm.
628   */
629  uint32_t                              cpu_time_budget;
630  /** This field is the algorithm used to manage this thread's time
631   *  quantum.  The algorithm may be specified as none which case,
632   *  no limit is in place.
633   */
634  Thread_CPU_budget_algorithms          budget_algorithm;
635  /** This field is the method invoked with the budgeted time is consumed. */
636  Thread_CPU_budget_algorithm_callout   budget_callout;
637  /** This field is the amount of CPU time consumed by this thread
638   *  since it was created.
639   */
640  Thread_CPU_usage_t                    cpu_time_used;
641
642  /** This field contains information about the starting state of
643   *  this thread.
644   */
645  Thread_Start_information              Start;
646
647  Thread_Action_control                 Post_switch_actions;
648
649  /** This field contains the context of this thread. */
650  Context_Control                       Registers;
651#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
652  /** This field points to the floating point context for this thread.
653   *  If NULL, the thread is integer only.
654   */
655  Context_Control_fp                   *fp_context;
656#endif
657  /** This field points to the newlib reentrancy structure for this thread. */
658  struct _reent                        *libc_reent;
659  /** This array contains the API extension area pointers. */
660  void                                 *API_Extensions[ THREAD_API_LAST + 1 ];
661
662#if !defined(RTEMS_SMP)
663  /** This field points to the set of per task variables. */
664  rtems_task_variable_t                *task_variables;
665#endif
666
667  /**
668   * This is the thread key value chain's control, which is used
669   * to track all key value for specific thread, and when thread
670   * exits, we can remove all key value for specific thread by
671   * iterating this chain, or we have to search a whole rbtree,
672   * which is inefficient.
673   */
674  Chain_Control           Key_Chain;
675
676  /**
677   * @brief Thread life-cycle control.
678   *
679   * Control state changes triggered by thread restart and delete requests.
680   */
681  Thread_Life_control                   Life;
682
683  Thread_Capture_control                Capture;
684
685  /**
686   * @brief Variable length array of user extension pointers.
687   *
688   * The length is defined by the application via <rtems/confdefs.h>.
689   */
690  void                                 *extensions[ RTEMS_ZERO_LENGTH_ARRAY ];
691};
692
693#if (CPU_PROVIDES_IDLE_THREAD_BODY == FALSE)
694/**
695 *  This routine is the body of the system idle thread.
696 *
697 *  NOTE: This routine is actually instantiated by confdefs.h when needed.
698 */
699void *_Thread_Idle_body(
700  uintptr_t  ignored
701);
702#endif
703
704/**  This defines the type for a method which operates on a single thread.
705 */
706typedef void (*rtems_per_thread_routine)( Thread_Control * );
707
708/**
709 *  @brief Iterates over all threads.
710 *  This routine iterates over all threads regardless of API and
711 *  invokes the specified routine.
712 */
713void rtems_iterate_over_all_threads(
714  rtems_per_thread_routine routine
715);
716
717/**
718 * @brief Returns the thread control block of the executing thread.
719 *
720 * This function can be called in any context.  On SMP configurations
721 * interrupts are disabled to ensure that the processor index is used
722 * consistently.
723 *
724 * @return The thread control block of the executing thread.
725 */
726RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Get_executing( void )
727{
728  Thread_Control *executing;
729
730  #if defined( RTEMS_SMP )
731    ISR_Level level;
732
733    _ISR_Disable_without_giant( level );
734  #endif
735
736  executing = _Thread_Executing;
737
738  #if defined( RTEMS_SMP )
739    _ISR_Enable_without_giant( level );
740  #endif
741
742  return executing;
743}
744
745/**
746 * @brief Thread control add-on.
747 */
748typedef struct {
749  /**
750   * @brief Offset of the pointer field in Thread_Control referencing an
751   * application configuration dependent memory area in the thread control
752   * block.
753   */
754  size_t destination_offset;
755
756  /**
757   * @brief Offset relative to the thread control block begin to an application
758   * configuration dependent memory area.
759   */
760  size_t source_offset;
761} Thread_Control_add_on;
762
763/**
764 * @brief Thread control add-ons.
765 *
766 * The thread control block contains fields that point to application
767 * configuration dependent memory areas, like the scheduler information, the
768 * API control blocks, the user extension context table, the RTEMS notepads and
769 * the Newlib re-entrancy support.  Account for these areas in the
770 * configuration and avoid extra workspace allocations for these areas.
771 *
772 * This array is provided via <rtems/confdefs.h>.
773 *
774 * @see _Thread_Control_add_on_count and _Thread_Control_size.
775 */
776extern const Thread_Control_add_on _Thread_Control_add_ons[];
777
778/**
779 * @brief Thread control add-on count.
780 *
781 * Count of entries in _Thread_Control_add_ons.
782 *
783 * This value is provided via <rtems/confdefs.h>.
784 */
785extern const size_t _Thread_Control_add_on_count;
786
787/**
788 * @brief Size of the thread control block of a particular application.
789 *
790 * This value is provided via <rtems/confdefs.h>.
791 *
792 * @see _Thread_Control_add_ons.
793 */
794extern const size_t _Thread_Control_size;
795
796/**@}*/
797
798#ifdef __cplusplus
799}
800#endif
801
802#endif
803/* end of include file */
Note: See TracBrowser for help on using the repository browser.