当前位置:网站首页>1292_ Implementation analysis of vtask resume() and xtask resume fromisr() in freeros

1292_ Implementation analysis of vtask resume() and xtask resume fromisr() in freeros

2022-07-06 21:39:00 grey_ csdn

All learning summary : GreyZhang/g_FreeRTOS: learning notes about FreeRTOS. (github.com)

Today, let's look at a relatively simple interface implementation ,vTaskResume() The implementation of the . It may be that the interface analyzed above has some precipitation , It's really not difficult to see this interface implementation this time , After all, the interface implementation involved in it has been analyzed before .

Many interfaces in the software actually don't work in my current configuration , So the rest of the code itself is not much .

Interface at the beginning , The way of assertion determines the validity of the task handle . Actually , With this , The state of one of the following conditions is confirmed , The later judgment is a little redundant when the assertion is on . The most basic judgment is to see whether the pending task handle is the handle of the current task , If it is , This operation is also meaningless . Because the current task is running , It will not be suspended ,

The basic prerequisites for processing have been met , The next step is to resume the suspended task . Of course , First of all, you have to confirm that the task is suspended . If it is , Remove from the pending task list , Then add it to the ready task list . such , The basic treatment is almost done .

If the scheduler is preemptive , At this time, we have to see whether the priority of the restored task is higher than that of the running task . If it is , That means you need to switch tasks .

This is the implementation of this interface , Relatively simple .

Look at the interruption of the safe version API, First, the validity of the handle is judged , Secondly, I looked at the effectiveness of interrupt priority . There is no need to judge the current execution Task The relationship between , Because in ISR in , Whether the scheduling is running or not is unknown .

Next , The overall treatment is the same as vTaskResume() Little difference , The only difference is the processing when the scheduler hangs .vTaskResume() Execution is in OS The scheduling code of , Therefore, the scheduler must not be suspended . But in ISR in , This is not necessarily , The state of the scheduler may be different . therefore , There is an additional scheduler pending processing .

原网站

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