ESP32 freeRTOS使用测试
[TOC]
此次测试是在menuconfig里面仅修改freeRTOS TICK的频率由100改为1000,其余设置均为默认。
同优先级任务的测试
0x00 同优先级任务都带挂起操作测试
在app_main启动时创建两个任务,代码如下:
void app_main(void)
{
PRINT_TITLE();
ESP_LOGI(TAG, " STARTING TEST FREERTOS ");
xTaskCreate(task1, "task1", 2048, NULL, 1, NULL);
xTaskCreate(task2, "task2", 2048, NULL, 1, NULL);
}
任务函数代码如下:
void task1(void *pvParameters)
{
for(;;)
{
vTaskDelay(100);
ESP_LOGI(TAG, "task1 running");
}
}
void task2(void *pvParameters)
{
for(;;)
{
vTaskDelay(200);
ESP_LOGI(TAG, "task2 running");
}
}
log显示:
I (305) cpu_start: Starting scheduler on PRO CPU.
======================================================================
______ _____ _____ __ _____ _______ ____ _____
| ____|/ ____| __ \ / _| | __ \__ __/ __ \ / ____|
| |__ | (___ | |__) | | |_ _ __ ___ ___| |__) | | | | | | | (___
| __| \___ \| ___/ | _| '__/ _ \/ _ \ _ / | | | | | |\___ \
| |____ ____) | | | | | | | __/ __/ | \ \ | | | |__| |____) |
|______|_____/|_| |_| |_| \___|\___|_| \_\ |_| \____/|_____/
======================================================================
I (411) ESP_FREERTOS_TEST: STARTING TEST FREERTOS
I (417) ESP_FREERTOS_TEST: create task1
I (521) ESP_FREERTOS_TEST: task1 running
I (621) ESP_FREERTOS_TEST: task2 running
I (621) ESP_FREERTOS_TEST: task1 running
I (721) ESP_FREERTOS_TEST: task1 running
I (821) ESP_FREERTOS_TEST: task2 running
I (821) ESP_FREERTOS_TEST: task1 running
I (921) ESP_FREERTOS_TEST: task1 running
I (1021) ESP_FREERTOS_TEST: task2 running
I (1021) ESP_FREERTOS_TEST: task1 running
可以看出task1执行的频率是task2的二倍。
0x01 同优先级任务其中一个不带挂起操作测试
和上面测试代码一样,去掉task1中vTaskDelay(100),log如下:
======================================================================
______ _____ _____ __ _____ _______ ____ _____
| ____|/ ____| __ \ / _| | __ \__ __/ __ \ / ____|
| |__ | (___ | |__) | | |_ _ __ ___ ___| |__) | | | | | | | (___
| __| \___ \| ___/ | _| '__/ _ \/ _ \ _ / | | | | | |\___ \
| |____ ____) | | | | | | | __/ __/ | \ \ | | | |__| |____) |
|______|_____/|_| |_| |_| \___|\___|_| \_\ |_| \____/|_____/
======================================================================
I (411) ESP_FREERTOS_TEST: STARTING TEST FREERTOS
I (417) ESP_FREERTOS_TEST: create task1
I (421) ESP_FREERTOS_TEST: task1 running
I (426) ESP_FREERTOS_TEST: task1 running
I (430) ESP_FREERTOS_TEST: task1 running
I (435) ESP_FREERTOS_TEST: task1 running
I (440) ESP_FREERTOS_TEST: task1 running
I (444) ESP_FREERTOS_TEST: task1 running
I (449) ESP_FREERTOS_TEST: task1 running
I (453) ESP_FREERTOS_TEST: task1 running
I (458) ESP_FREERTOS_TEST: task1 running
I (463) ESP_FREERTOS_TEST: task1 running
I (467) ESP_FREERTOS_TEST: task1 running
I (472) ESP_FREERTOS_TEST: task1 running
I (476) ESP_FREERTOS_TEST: task1 running
I (481) ESP_FREERTOS_TEST: task1 running
I (486) ESP_FREERTOS_TEST: task1 running
I (490) ESP_FREERTOS_TEST: task1 running
I (495) ESP_FREERTOS_TEST: task1 running
I (499) ESP_FREERTOS_TEST: task1 running
I (504) ESP_FREERTOS_TEST: task1 running
I (509) ESP_FREERTOS_TEST: task1 running
I (513) ESP_FREERTOS_TEST: task1 running
I (518) ESP_FREERTOS_TEST: task1 running
I (522) ESP_FREERTOS_TEST: task1 running
I (527) ESP_FREERTOS_TEST: task1 running
I (532) ESP_FREERTOS_TEST: task1 running
I (536) ESP_FREERTOS_TEST: task1 running
I (541) ESP_FREERTOS_TEST: task1 running
I (545) ESP_FREERTOS_TEST: task1 running
I (550) ESP_FREERTOS_TEST: task1 running
I (555) ESP_FREERTOS_TEST: task1 running
I (559) ESP_FREERTOS_TEST: task1 running
I (564) ESP_FREERTOS_TEST: task1 running
I (568) ESP_FREERTOS_TEST: task1 running
I (573) ESP_FREERTOS_TEST: task1 running
I (578) ESP_FREERTOS_TEST: task1 running
I (582) ESP_FREERTOS_TEST: task1 running
I (587) ESP_FREERTOS_TEST: task1 running
I (591) ESP_FREERTOS_TEST: task1 running
I (596) ESP_FREERTOS_TEST: task1 running
I (601) ESP_FREERTOS_TEST: task1 running
I (605) ESP_FREERTOS_TEST: task1 running
I (610) ESP_FREERTOS_TEST: task1 running
I (614) ESP_FREERTOS_TEST: task1 running
I (619) ESP_FREERTOS_TEST: task1 running
I (622) ESP_FREERTOS_TEST: task2 running
I (625) ESP_FREERTOS_TEST: task1 running
从log可以看出task2两百毫秒左右被执行一次,其间task1一直在运行。
0x02 同优先级任务都不带挂起操作测试
这次我将两个任务的vTaskDelay()都去掉,log如下:
I (305) cpu_start: Starting scheduler on PRO CPU.
======================================================================
______ _____ _____ __ _____ _______ ____ _____
| ____|/ ____| __ \ / _| | __ \__ __/ __ \ / ____|
| |__ | (___ | |__) | | |_ _ __ ___ ___| |__) | | | | | | | (___
| __| \___ \| ___/ | _| '__/ _ \/ _ \ _ / | | | | | |\___ \
| |____ ____) | | | | | | | __/ __/ | \ \ | | | |__| |____) |
|______|_____/|_| |_| |_| \___|\___|_| \_\ |_| \____/|_____/
======================================================================
I (411) ESP_FREERTOS_TEST: STARTING TEST FREERTOS
I (417) ESP_FREERTOS_TEST: create task1
I (421) ESP_FREERTOS_TEST: task1 running
I (422) ESP_FREERTOS_TEST: task2 running
I (427) ESP_FREERTOS_TEST: task1 running
I (431) ESP_FREERTOS_TEST: task2 running
I (436) ESP_FREERTOS_TEST: task1 running
I (441) ESP_FREERTOS_TEST: task2 running
I (445) ESP_FREERTOS_TEST: task1 running
I (450) ESP_FREERTOS_TEST: task2 running
可以看出来,这次两个任务已经开始真正的交替执行了。
0x03 对于同优先级任务的结论:
- 所有任务都会被执行
- 任务在被挂起时,其他任务立即被执行
- 挂起结束后可在当前运行任务运行结束后开始执行
不同优先级任务的测试
0x00 不同优先级任务都带挂起操作测试
在app_main启动时创建两个任务,代码如下:
void app_main(void)
{
PRINT_TITLE();
ESP_LOGI(TAG, " STARTING TEST FREERTOS ");
ESP_LOGI(TAG, "create task1");
xTaskCreate(task1, "task1", 2048, NULL, 2, NULL);
xTaskCreate(task2, "task2", 2048, NULL, 1, NULL);
}
任务函数代码如下:
void task1(void *pvParameters)
{
for(;;)
{
vTaskDelay(100);
ESP_LOGI(TAG, "task1 running");
}
}
void task2(void *pvParameters)
{
for(;;)
{
vTaskDelay(200);
ESP_LOGI(TAG, "task2 running");
}
}
log显示:
I (305) cpu_start: Starting scheduler on PRO CPU.
======================================================================
______ _____ _____ __ _____ _______ ____ _____
| ____|/ ____| __ \ / _| | __ \__ __/ __ \ / ____|
| |__ | (___ | |__) | | |_ _ __ ___ ___| |__) | | | | | | | (___
| __| \___ \| ___/ | _| '__/ _ \/ _ \ _ / | | | | | |\___ \
| |____ ____) | | | | | | | __/ __/ | \ \ | | | |__| |____) |
|______|_____/|_| |_| |_| \___|\___|_| \_\ |_| \____/|_____/
======================================================================
I (411) ESP_FREERTOS_TEST: STARTING TEST FREERTOS
I (417) ESP_FREERTOS_TEST: create task1
I (521) ESP_FREERTOS_TEST: task1 running
I (621) ESP_FREERTOS_TEST: task1 running
I (621) ESP_FREERTOS_TEST: task2 running
I (721) ESP_FREERTOS_TEST: task1 running
I (821) ESP_FREERTOS_TEST: task1 running
I (821) ESP_FREERTOS_TEST: task2 running
I (921) ESP_FREERTOS_TEST: task1 running
从log可以看出,task1执行频率是task2频率的二倍,这与同优先级的测试结果一致。
0x01 不同优先级任务高优先级任务不带挂起操作测试
在task1里去掉vTaskDelay(100);,log如下:
I (305) cpu_start: Starting scheduler on PRO CPU.
======================================================================
______ _____ _____ __ _____ _______ ____ _____
| ____|/ ____| __ \ / _| | __ \__ __/ __ \ / ____|
| |__ | (___ | |__) | | |_ _ __ ___ ___| |__) | | | | | | | (___
| __| \___ \| ___/ | _| '__/ _ \/ _ \ _ / | | | | | |\___ \
| |____ ____) | | | | | | | __/ __/ | \ \ | | | |__| |____) |
|______|_____/|_| |_| |_| \___|\___|_| \_\ |_| \____/|_____/
======================================================================
I (411) ESP_FREERTOS_TEST: STARTING TEST FREERTOS
I (417) ESP_FREERTOS_TEST: create task1
I (421) ESP_FREERTOS_TEST: task1 running
I (426) ESP_FREERTOS_TEST: task1 running
I (430) ESP_FREERTOS_TEST: task1 running
I (435) ESP_FREERTOS_TEST: task1 running
I (440) ESP_FREERTOS_TEST: task1 running
I (444) ESP_FREERTOS_TEST: task1 running
I (449) ESP_FREERTOS_TEST: task1 running
I (453) ESP_FREERTOS_TEST: task1 running
I (458) ESP_FREERTOS_TEST: task1 running
I (463) ESP_FREERTOS_TEST: task1 running
I (467) ESP_FREERTOS_TEST: task1 running
I (472) ESP_FREERTOS_TEST: task1 running
I (476) ESP_FREERTOS_TEST: task1 running
I (481) ESP_FREERTOS_TEST: task1 running
I (486) ESP_FREERTOS_TEST: task1 running
I (490) ESP_FREERTOS_TEST: task1 running
I (495) ESP_FREERTOS_TEST: task1 running
I (499) ESP_FREERTOS_TEST: task1 running
I (504) ESP_FREERTOS_TEST: task1 running
I (509) ESP_FREERTOS_TEST: task1 running
I (513) ESP_FREERTOS_TEST: task1 running
I (518) ESP_FREERTOS_TEST: task1 running
I (522) ESP_FREERTOS_TEST: task1 running
I (527) ESP_FREERTOS_TEST: task1 running
I (532) ESP_FREERTOS_TEST: task1 running
I (536) ESP_FREERTOS_TEST: task1 running
I (541) ESP_FREERTOS_TEST: task1 running
I (545) ESP_FREERTOS_TEST: task1 running
I (550) ESP_FREERTOS_TEST: task1 running
I (555) ESP_FREERTOS_TEST: task1 running
I (559) ESP_FREERTOS_TEST: task1 running
I (564) ESP_FREERTOS_TEST: task1 running
I (568) ESP_FREERTOS_TEST: task1 running
I (573) ESP_FREERTOS_TEST: task1 running
I (578) ESP_FREERTOS_TEST: task1 running
I (582) ESP_FREERTOS_TEST: task1 running
I (587) ESP_FREERTOS_TEST: task1 running
I (591) ESP_FREERTOS_TEST: task1 running
I (596) ESP_FREERTOS_TEST: task1 running
I (601) ESP_FREERTOS_TEST: task1 running
I (605) ESP_FREERTOS_TEST: task1 running
I (610) ESP_FREERTOS_TEST: task1 running
I (614) ESP_FREERTOS_TEST: task1 running
I (619) ESP_FREERTOS_TEST: task1 running
I (624) ESP_FREERTOS_TEST: task1 running
I (628) ESP_FREERTOS_TEST: task1 running
I (633) ESP_FREERTOS_TEST: task1 running
I (637) ESP_FREERTOS_TEST: task1 running
I (642) ESP_FREERTOS_TEST: task1 running
I (647) ESP_FREERTOS_TEST: task1 running
I (651) ESP_FREERTOS_TEST: task1 running
I (656) ESP_FREERTOS_TEST: task1 running
I (660) ESP_FREERTOS_TEST: task1 running
I (665) ESP_FREERTOS_TEST: task1 running
I (670) ESP_FREERTOS_TEST: task1 running
I (674) ESP_FREERTOS_TEST: task1 running
I (679) ESP_FREERTOS_TEST: task1 running
I (683) ESP_FREERTOS_TEST: task1 running
I (688) ESP_FREERTOS_TEST: task1 running
I (693) ESP_FREERTOS_TEST: task1 running
...
�[0;3E (5361) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (5361) task_wdt: - IDLE (CPU 0)
E (5361) task_wdt: Tasks currently running:
E (5361) task_wdt: CPU 0: task1
E (5361) task_wdt: Print CPU 0 (current core) backtrace
...
从log中我们可以看到task1一直在执行,task2没机会执行,而且触发了死循环任务看门狗。
0x02 不同优先级任务低优先级任务不带挂起操作测试
这次我们恢复task1的vTaskDelay(100);,去掉task2的vTaskDelay(200);,log如下:
I (305) cpu_start: Starting scheduler on PRO CPU.
======================================================================
______ _____ _____ __ _____ _______ ____ _____
| ____|/ ____| __ \ / _| | __ \__ __/ __ \ / ____|
| |__ | (___ | |__) | | |_ _ __ ___ ___| |__) | | | | | | | (___
| __| \___ \| ___/ | _| '__/ _ \/ _ \ _ / | | | | | |\___ \
| |____ ____) | | | | | | | __/ __/ | \ \ | | | |__| |____) |
|______|_____/|_| |_| |_| \___|\___|_| \_\ |_| \____/|_____/
======================================================================
I (411) ESP_FREERTOS_TEST: STARTING TEST FREERTOS
I (417) ESP_FREERTOS_TEST: create task1
I (421) ESP_FREERTOS_TEST: task2 running
I (426) ESP_FREERTOS_TEST: task2 running
I (430) ESP_FREERTOS_TEST: task2 running
I (435) ESP_FREERTOS_TEST: task2 running
I (440) ESP_FREERTOS_TEST: task2 running
I (444) ESP_FREERTOS_TEST: task2 running
I (449) ESP_FREERTOS_TEST: task2 running
I (453) ESP_FREERTOS_TEST: task2 running
I (458) ESP_FREERTOS_TEST: task2 running
I (463) ESP_FREERTOS_TEST: task2 running
I (467) ESP_FREERTOS_TEST: task2 running
I (472) ESP_FREERTOS_TEST: task2 running
I (476) ESP_FREERTOS_TEST: task2 running
I (481) ESP_FREERTOS_TEST: task2 running
I (486) ESP_FREERTOS_TEST: task2 running
I (490) ESP_FREERTOS_TEST: task2 running
I (495) ESP_FREERTOS_TEST: task2 running
I (499) ESP_FREERTOS_TEST: task2 running
I (504) ESP_FREERTOS_TEST: task2 running
I (509) ESP_FREERTOS_TEST: task2 running
I (513) ESP_FREERTOS_TEST: task2 running
I (518) ESP_FREERTOS_TEST: task2 running
I (521) ESP_FREERTOS_TEST: task1 running
I (527) ESP_FREERTOS_TEST: task2 running
I (532) ESP_FREERTOS_TEST: task2 running
I (536) ESP_FREERTOS_TEST: task2 running
I (541) ESP_FREERTOS_TEST: task2 running
I (545) ESP_FREERTOS_TEST: task2 running
I (550) ESP_FREERTOS_TEST: task2 running
I (555) ESP_FREERTOS_TEST: task2 running
I (559) ESP_FREERTOS_TEST: task2 running
I (564) ESP_FREERTOS_TEST: task2 running
I (568) ESP_FREERTOS_TEST: task2 running
I (573) ESP_FREERTOS_TEST: task2 running
I (578) ESP_FREERTOS_TEST: task2 running
I (582) ESP_FREERTOS_TEST: task2 running
I (587) ESP_FREERTOS_TEST: task2 running
I (591) ESP_FREERTOS_TEST: task2 running
I (596) ESP_FREERTOS_TEST: task2 running
I (601) ESP_FREERTOS_TEST: task2 running
I (605) ESP_FREERTOS_TEST: task2 running
I (610) ESP_FREERTOS_TEST: task2 running
I (614) ESP_FREERTOS_TEST: task2 running
I (619) ESP_FREERTOS_TEST: task2 running
I (624) ESP_FREERTOS_TEST: task2 running
I (627) ESP_FREERTOS_TEST: task1 running
I (633) ESP_FREERTOS_TEST: task2 running
I (637) ESP_FREERTOS_TEST: task2 running
I (642) ESP_FREERTOS_TEST: task2 running
从log可以看出,task1挂起之后task2开始执行,一直到task1挂起结束。
0x03 不同优先级任务都不带挂起操作测试
把两个任务vTaskDelay都去掉,log如下:
I (305) cpu_start: Starting scheduler on PRO CPU.
======================================================================
______ _____ _____ __ _____ _______ ____ _____
| ____|/ ____| __ \ / _| | __ \__ __/ __ \ / ____|
| |__ | (___ | |__) | | |_ _ __ ___ ___| |__) | | | | | | | (___
| __| \___ \| ___/ | _| '__/ _ \/ _ \ _ / | | | | | |\___ \
| |____ ____) | | | | | | | __/ __/ | \ \ | | | |__| |____) |
|______|_____/|_| |_| |_| \___|\___|_| \_\ |_| \____/|_____/
======================================================================
I (411) ESP_FREERTOS_TEST: STARTING TEST FREERTOS
I (417) ESP_FREERTOS_TEST: create task1
I (421) ESP_FREERTOS_TEST: task1 running
I (426) ESP_FREERTOS_TEST: task1 running
I (430) ESP_FREERTOS_TEST: task1 running
I (435) ESP_FREERTOS_TEST: task1 running
I (440) ESP_FREERTOS_TEST: task1 running
I (444) ESP_FREERTOS_TEST: task1 running
I (449) ESP_FREERTOS_TEST: task1 running
I (453) ESP_FREERTOS_TEST: task1 running
I (458) ESP_FREERTOS_TEST: task1 running
I (463) ESP_FREERTOS_TEST: task1 running
I (467) ESP_FREERTOS_TEST: task1 running
I (472) ESP_FREERTOS_TEST: task1 running
I (476) ESP_FREERTOS_TEST: task1 running
I (481) ESP_FREERTOS_TEST: task1 running
I (486) ESP_FREERTOS_TEST: task1 running
I (490) ESP_FREERTOS_TEST: task1 running
I (495) ESP_FREERTOS_TEST: task1 running
I (499) ESP_FREERTOS_TEST: task1 running
I (504) ESP_FREERTOS_TEST: task1 running
I (509) ESP_FREERTOS_TEST: task1 running
I (513) ESP_FREERTOS_TEST: task1 running
I (518) ESP_FREERTOS_TEST: task1 running
I (522) ESP_FREERTOS_TEST: task1 running
I (527) ESP_FREERTOS_TEST: task1 running
I (532) ESP_FREERTOS_TEST: task1 running
I (536) ESP_FREERTOS_TEST: task1 running
I (541) ESP_FREERTOS_TEST: task1 running
I (545) ESP_FREERTOS_TEST: task1 running
I (550) ESP_FREERTOS_TEST: task1 running
I (555) ESP_FREERTOS_TEST: task1 running
I (559) ESP_FREERTOS_TEST: task1 running
I (564) ESP_FREERTOS_TEST: task1 running
I (568) ESP_FREERTOS_TEST: task1 running
I (573) ESP_FREERTOS_TEST: task1 running
I (578) ESP_FREERTOS_TEST: task1 running
I (582) ESP_FREERTOS_TEST: task1 running
I (587) ESP_FREERTOS_TEST: task1 running
I (591) ESP_FREERTOS_TEST: task1 running
I (596) ESP_FREERTOS_TEST: task1 running
I (601) ESP_FREERTOS_TEST: task1 running
I (605) ESP_FREERTOS_TEST: task1 running
I (610) ESP_FREERTOS_TEST: task1 running
I (614) ESP_FREERTOS_TEST: task1 running
I (619) ESP_FREERTOS_TEST: task1 running
I (624) ESP_FREERTOS_TEST: task1 running
I (628) ESP_FREERTOS_TEST: task1 running
I (633) ESP_FREERTOS_TEST: task1 running
I (637) ESP_FREERTOS_TEST: task1 running
I (642) ESP_FREERTOS_TEST: task1 running
I (647) ESP_FREERTOS_TEST: task1 running
I (651) ESP_FREERTOS_TEST: task1 running
I (656) ESP_FREERTOS_TEST: task1 running
看log结果task1一直在运行。
0x04 对于不同优先级任务的结论:
- 有的任务有可能永远不被执行
- 只有高优先级任务挂起,低优先级任务才能被执行
结论
ESP freeRTOS运行在抢占+时间片轮训模式,高优先级任务挂起,低优先级任务才有机会被执行。同优先级任务轮训执行,执行粒度为时间片,即一个时间片结束,另一个任务才开始执行。抢占模式在使用时一定要画任务时序图,不然低优先级任务可能执行周期过长,或者根本不能执行!
补充
为说明执行粒度,程序做一下修改:
void task1(void *pvParameters)
{
for(;;)
{
for (int i = 0; i < 1000; i++)
{
ESP_LOGI(TAG, "task1 running");
}
}
}
void task2(void *pvParameters)
{
for(;;)
{
for (int i = 0; i < 1000; i++)
{
ESP_LOGI(TAG, "task2 running");
}
}
}
void app_main(void)
{
PRINT_TITLE();
ESP_LOGI(TAG, " STARTING TEST FREERTOS ");
ESP_LOGI(TAG, "create task1");
xTaskCreate(task1, "task1", 2048, NULL, 1, NULL);
xTaskCreate(task2, "task2", 2048, NULL, 1, NULL);
}
log如下:
I (305) cpu_start: Starting scheduler on PRO CPU.
======================================================================
______ _____ _____ __ _____ _______ ____ _____
| ____|/ ____| __ \ / _| | __ \__ __/ __ \ / ____|
| |__ | (___ | |__) | | |_ _ __ ___ ___| |__) | | | | | | | (___
| __| \___ \| ___/ | _| '__/ _ \/ _ \ _ / | | | | | |\___ \
| |____ ____) | | | | | | | __/ __/ | \ \ | | | |__| |____) |
|______|_____/|_| |_| |_| \___|\___|_| \_\ |_| \____/|_____/
======================================================================
I (411) ESP_FREERTOS_TEST: STARTING TEST FREERTOS
I (417) ESP_FREERTOS_TEST: create task1
I (421) ESP_FREERTOS_TEST: task1 running
I (422) ESP_FREERTOS_TEST: task2 running
I (427) ESP_FREERTOS_TEST: task1 running
I (431) ESP_FREERTOS_TEST: task2 running
I (436) ESP_FREERTOS_TEST: task1 running
I (441) ESP_FREERTOS_TEST: task2 running
I (445) ESP_FREERTOS_TEST: task1 running
I (450) ESP_FREERTOS_TEST: task2 running
I (454) ESP_FREERTOS_TEST: task1 running
I (459) ESP_FREERTOS_TEST: task2 running
I (464) ESP_FREERTOS_TEST: task1 running
I (468) ESP_FREERTOS_TEST: task2 running
I (473) ESP_FREERTOS_TEST: task1 running
I (477) ESP_FREERTOS_TEST: task2 running
I (482) ESP_FREERTOS_TEST: task1 running
I (487) ESP_FREERTOS_TEST: task2 running
I (491) ESP_FREERTOS_TEST: task1 running
I (496) ESP_FREERTOS_TEST: task2 running
I (500) ESP_FREERTOS_TEST: task1 running
I (505) ESP_FREERTOS_TEST: task2 running
I (510) ESP_FREERTOS_TEST: task1 running
I (514) ESP_FREERTOS_TEST: task2 running
task1和task2的log交替打出说明执行的粒度不是以任务为单位,而是以时间片为单位。