BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
const char * const pcName,/*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const configSTACK_DEPTH_TYPE usStackDepth,
void * const pvParameters,
UBaseType_t uxPriority,
TaskHandle_t * const pxCreatedTask )//任务句柄函数原型
xReturned = xTaskCreate(
vTaskCode, /* Function that implements the task. */
"NAME", /* Text name for the task. */
STACK_SIZE, /* Stack size in words, not bytes. */
( void * ) 1, /* Parameter passed into the task. */
tskIDLE_PRIORITY,/* Priority at which the task is created. */
&xHandle ); /* Used to pass out the created task's handle.//任务句柄函数原型 */
- 最后一个参数是任务句柄参数(简称:TCB)TaskControlBlock
- 翻译如下:用于传递创建的任务句柄
- 估计看到这也不知道啥意思,请往下看 TaskHandle_t 任务句柄函数指针的定义
struct tskTaskControlBlock; /* 原型 The old naming convention is used
to prevent breaking kernel aware debuggers. */
typedef struct tskTaskControlBlock* TaskHandle_t;/*重新定义了*/
/*
* 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 /* The old naming convention is used to prevent breaking kernel aware debuggers. */
{
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 ). */
ListItem_t xEventListItem; /*任务事件列表< Used to reference a task from an event list. */
UBaseType_t uxPriority; /*优先级< The priority of the task. 0 is the lowest priority. */
StackType_t *pxStack; /*栈指针< Points to the start of the stack. */
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. */
} tskTCB;//说明任务句柄包含创建任务的所有状态,说成任务的身份证最为合适,想删除,直接抹掉身份证就可以了
- 说明任务句柄包含创建任务的所有状态,说成任务的身份证最为合适,想删除,直接抹掉身份证就可以了
/*
* 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)
*任务控制块。 为每个任务分配一个任务控制块(TCB),
*并存储任务状态信息,包括指向任务上下文的指针
*(任务的运行时环境,包括寄存器值)
*/
- 任务句柄,在FreeRTOS又叫任务控制块,包含创建任务的所有信息,所有删除任务就可以这样来做
/* 任务创建后,用删除任务句柄来删除此任务The task was created. Use the task's handle to delete the task. */
vTaskDelete( xHandle );