当前位置:网站首页>Dead loop in FreeRTOS task function

Dead loop in FreeRTOS task function

2022-07-06 11:59:00 Weiyuan escort agency

         The task function is an infinite loop function with no return value .

         The task must be an endless cycle , Otherwise, the task will pass LR return , If LR Pointing to illegal memory will generate HardFault_Handler, and FreeRTOS Point to a dead cycle , Then the task will be executed in the dead loop after it returns , Such a task is not safe .

         This should be avoided when programming , Tasks are usually closed-loop and have no return value .

         If it's a single task , Delete after one execution , It will not affect the operation of the system , therefore , Remember to delete tasks that are only executed once after execution . namely At the end of the mission , add  vTaskDelete(NULL).

        In the circular task The delay function must use FreeRTOS The delay function provided inside , We can't use the kind of delay in bare metal programming . The difference between these two delays is FreeRTOS The delay inside is blocking delay , That is to call vTaskDelay() Function , The current task will be suspended , The scheduler switches to other ready tasks , So as to realize multitasking . If you still use the delay in bare metal programming , Then the whole task becomes an endless cycle , If it happens, the priority of this task is the highest , Then the system will always run in this task , Tasks with lower priority cannot be run , There is no way to multitask .

         When the task enters the delay , Because there is no other user task ready , Then the system will enter idle tasks , Idle tasks are FreeRTOS A task started by the system itself , The lowest priority . When the whole system has no ready task , The system must ensure that there is a task running , Idle tasks are designed for this . When the user task delay expires , It will switch back from idle task to user task .

原网站

版权声明
本文为[Weiyuan escort agency]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060913225303.html