- Task control block, 即任务控制块。任务控制块(TCB)是一个结构体,它会分配给每个任务,其中存储着任务的状态信息,包括指向任务上下文(任务的运行时环境,包括寄存器值)的指针。
- 任务控制块就像是任务的身份ID,必不可少。
- 基于DSP芯片TMS320F28377D上移植到FreeRTOS系统。
1. 源码定义
- 注意,已经根据宏定义,在源码中去除了未用到的部分。
/*
* Task control block. A task control block (TCB) is allocated for each task,
* and stores task state information, including a pointer to the task's context
* (the task's run time environment, including register values)
*/
typedef struct tskTaskControlBlock
{
/* 指向任务堆栈中最后一个项目的位置。这必须是TCB结构的第一个成员 */
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. */
/* 任务的状态列表项所引用的列表,用来表示该任务的状态(就绪、阻止、挂起) */
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 ). */
/* 用于从事件列表中引用任务 */