This blog is used to record how to use FreeRTOS to print the current task list, task status priority, usage rate and other information.
1. vTaskList
Use vTaskList() to print
- Task name
- Task status
- priority
- Remaining stack
- Task number
Examples of usage are as follows:
void app_main()
{
xTaskCreate(test_task, "test_task", 4096, NULL, 6, NULL);
static char InfoBuffer[512] = {
0};
while (1) {
vTaskList((char *) &InfoBuffer);
printf("任务名 任务状态 优先级 剩余栈 任务序号\r\n");
printf("\r\n%s\r\n", InfoBuffer);
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
}
The corresponding log is printed as follows:
任务名 任务状态 优先级 剩余栈 任务序号
main R 1 2996 2
IDLE0 R 0 1232 3
test_task B 6 3460 5
Tmr Svc B 1 2684 4
esp_timer B 22 3632 1
2. vTaskGetRunTimeStats
Use vTaskGetRunTimeStats() to print
- Task name
- Run count
- Usage rate
Examples of usage are as follows:
void app_main()
{
xTaskCreate(test_task, "test_task", 4096, NULL, 6, NULL);
static char InfoBuffer[512] = {
0};
while (1) {
vTaskGetRunTimeStats((char *) &InfoBuffer);
printf("\r\n任务名 运行计数 使用率\r\n");
printf("\r\n%s\r\n", InfoBuffer);
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
}
The corresponding log is printed as follows:
任务名 运行计数 使用率
main 56475 <1%
IDLE0 4091951 48%
test_task 4328356 50%
Tmr Svc 35 <1%
esp_timer 17606 <1%