task_control_block.h 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #pragma once
  2. #include <FreeRTOS.h>
  3. #include <task.h>
  4. typedef struct {
  5. volatile StackType_t * pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */
  6. #if ( portUSING_MPU_WRAPPERS == 1 )
  7. xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer. THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */
  8. #endif
  9. ListItem_t xStateListItem; /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */
  10. ListItem_t xEventListItem; /*< Used to reference a task from an event list. */
  11. UBaseType_t uxPriority; /*< The priority of the task. 0 is the lowest priority. */
  12. StackType_t * pxStack; /*< Points to the start of the stack. */
  13. char pcTaskName[ configMAX_TASK_NAME_LEN ]; /*< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  14. #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
  15. StackType_t * pxEndOfStack; /*< Points to the highest valid address for the stack. */
  16. #endif
  17. #if ( portCRITICAL_NESTING_IN_TCB == 1 )
  18. UBaseType_t uxCriticalNesting; /*< Holds the critical section nesting depth for ports that do not maintain their own count in the port layer. */
  19. #endif
  20. #if ( configUSE_TRACE_FACILITY == 1 )
  21. UBaseType_t uxTCBNumber; /*< Stores a number that increments each time a TCB is created. It allows debuggers to determine when a task has been deleted and then recreated. */
  22. UBaseType_t uxTaskNumber; /*< Stores a number specifically for use by third party trace code. */
  23. #endif
  24. #if ( configUSE_MUTEXES == 1 )
  25. UBaseType_t uxBasePriority; /*< The priority last assigned to the task - used by the priority inheritance mechanism. */
  26. UBaseType_t uxMutexesHeld;
  27. #endif
  28. #if ( configUSE_APPLICATION_TASK_TAG == 1 )
  29. TaskHookFunction_t pxTaskTag;
  30. #endif
  31. #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
  32. void * pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
  33. #endif
  34. #if ( configGENERATE_RUN_TIME_STATS == 1 )
  35. configRUN_TIME_COUNTER_TYPE ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */
  36. #endif
  37. #if ( configUSE_NEWLIB_REENTRANT == 1 )
  38. /* Allocate a Newlib reent structure that is specific to this task.
  39. * Note Newlib support has been included by popular demand, but is not
  40. * used by the FreeRTOS maintainers themselves. FreeRTOS is not
  41. * responsible for resulting newlib operation. User must be familiar with
  42. * newlib and must provide system-wide implementations of the necessary
  43. * stubs. Be warned that (at the time of writing) the current newlib design
  44. * implements a system-wide malloc() that must be provided with locks.
  45. *
  46. * See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
  47. * for additional information. */
  48. struct _reent xNewLib_reent;
  49. #endif
  50. #if ( configUSE_TASK_NOTIFICATIONS == 1 )
  51. volatile uint32_t ulNotifiedValue[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];
  52. volatile uint8_t ucNotifyState[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];
  53. #endif
  54. /* See the comments in FreeRTOS.h with the definition of
  55. * tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE. */
  56. #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */
  57. uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the task is a statically allocated to ensure no attempt is made to free the memory. */
  58. #endif
  59. #if ( INCLUDE_xTaskAbortDelay == 1 )
  60. uint8_t ucDelayAborted;
  61. #endif
  62. #if ( configUSE_POSIX_ERRNO == 1 )
  63. int iTaskErrno;
  64. #endif
  65. } TaskControlBlock;