ESP32 freeRTOS使用测试

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交替打出说明执行的粒度不是以任务为单位,而是以时间片为单位。

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,454评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,553评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,921评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,648评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,770评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,950评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,090评论 3 410
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,817评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,275评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,592评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,724评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,409评论 4 333
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,052评论 3 316
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,815评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,043评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,503评论 2 361
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,627评论 2 350

推荐阅读更多精彩内容

  • 任务一: 任务的创建与切换 实验内容 在本实验中将要创建两个任务,一个低优先级任务task1,一个高优先级任务ta...
    曲中人_a7e0阅读 337评论 0 0
  • 任务一: 任务的创建与切换 实验内容 在本实验中将要创建两个任务,一个低优先级任务task1,一个高优先级任务ta...
    独孤尚青阅读 431评论 0 0
  • 任务一 体验任务的创建与切换实验内容本实验中将创建两个任务,一个低优先级任务task1,一个高优先级任务ta...
  • 本次内容主要以 为主, 、 、 、 、 ,以及 , 及 。在 中,一个任务就是一个线程,多个任务按照优先级进行抢占...
    窥菏阅读 1,608评论 1 0
  • LiteOS内核的任务管理 Huawei LiteOS 任务管理模块提供任务创建、任务删除、任务延时、任务挂起和任...
    灰仙杯小智阅读 128评论 0 1