当前位置:网站首页>1286_ Implementation analysis of task priority setting in FreeRTOS
1286_ Implementation analysis of task priority setting in FreeRTOS
2022-07-01 07:04:00 【grey_ csdn】
All learning summary : GitHub - GreyZhang/g_FreeRTOS: learning notes about FreeRTOS.
The previous simple analysis of priority acquisition , It's easy to implement . Priority acquisition is divided into general OS API There is also an interrupt safe version . In the specific implementation, there is not much difficult to understand in the code implementation , It's just a property acquisition . This time, let's look at the priority setting implementation , Different from priority acquisition , Setting actually has only one interface .

First, ensure that the priority value set is reasonable , Then the actual priority is calculated according to the allowed number of priorities .

Next, enter critical protection , Get the current basic priority of the priority task to be modified .

Only when the current basic priority of the task to be modified is not equal to the priority to be modified , If it is modified, it will be divided into two possibilities: priority increase and priority decrease . Because the priority may be higher than that of the currently running task , In this case, you need to switch tasks . however , There are two possibilities for higher priority than the currently running priority . Or other tasks are higher than the current task , Or the current task itself needs to be upgraded . For the latter , In fact, the current task is already the highest priority ready task , Then there will be no Scheduling switching is required .

If the task whose priority is modified is not the current task , It also requires scheduling . There is no trouble with the design here , At first I thought I would look at the second highest ready priority , Make a comparison with it .

I don't understand at the moment uxBasePriority The function of attributes , But from this precompiled information , It should be an attribute state implemented to support mutually exclusive signals .

This part is mainly aimed at the support of event function , I haven't tested or analyzed this function yet . look , Analyze the whole FreeRTOS It still takes some events to implement .

After modifying the priority of the task , The task may not be in the previous task ready list . So there is a removal process , There is no need to worry about setting the same priority , Because the previous branch has directly skipped such processing . After the pending task is removed from the previous priority ready task list , If the removed linked list is empty, you should do something reset.

The latter part is easy to understand , If task scheduling is required, make a scheduling request . after , Exit critical protection .
Compared with priority acquisition , This is indeed a little more complicated . The main difference lies in the processing of task switching , Because the acquisition of priority does not involve any change of priority, it will not destroy the judgment basis of scheduling . However, the priority setting has a big deviation , This may trigger task scheduling due to priority adjustment . therefore , A little more complexity . But overall , It's not hard either . Read a lot of function implementation analysis , Then consider the practical application , In fact, under my current use needs OS It should be able to cut to a smaller size .
Whole OS The mechanism of is not difficult to understand now , But it doesn't mean it's not difficult , After all, the difficulties may be hidden in the details of interrupt protection . If you think it all over , It may still take a lot of effort .
边栏推荐
- 【电气介数】电气介数及考虑HVDC和FACTS元件的电气介数计算
- MySQL constraint learning notes
- 女生适合学产品经理吗?有什么优势?
- TDB中多个model情况下使用fuseki查询
- [lingo] solve quadratic programming
- Fix the problem that the AI video intelligent platform easycvr device video cannot be played
- Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)
- Code practice - build your own diffusion models / score based generic models from scratch
- Esp32 monitors the battery voltage with ULP when the battery is powered
- 盘点华为云GaussDB(for Redis)六大秒级能力
猜你喜欢
![[recommendation technology] matlab simulation of network information recommendation technology based on collaborative filtering](/img/fb/dc03f97f12488e53d706a05da9faea.png)
[recommendation technology] matlab simulation of network information recommendation technology based on collaborative filtering

Some pits designed by NOC

(上)苹果有开源,但又怎样呢?

8 figures | analyze Eureka's first synchronization registry

Image style migration cyclegan principle

EasyNVS云管理平台功能重构:支持新增用户、修改信息等

The game is real! China software cup releases a new industrial innovation competition, and schools and enterprises can participate in it jointly

Using fuseki query when there are multiple models in TDB

ctfshow-web352,353(SSRF)

ctfshow-web351(SSRF)
随机推荐
H5 web page determines whether an app is installed. If it is installed, it will jump to the summary of the scheme to download if it is not installed
女生适合学产品经理吗?有什么优势?
了解ESP32睡眠模式及其功耗
【图像处理】图像直方图均衡化系统含GUI界面
如何通过cdn方式使用阿里巴巴矢量图字体文件
在长城证券上做基金定投安全吗?
運維管理系統,人性化操作體驗
如何画产品架构图?
SQL learning notes 2
Insufficient free space after clearing expired cache entries - consider increasing the maximum cache space
SQL learning notes nine connections 2
为什么这么多人转行产品经理?产品经理发展前景如何?
K8S搭建Redis集群
Spark入门(一篇就够了)
[Electrical dielectric number] electrical dielectric number and calculation considering HVDC and facts components
Product learning (II) - competitive product analysis
1286_FreeRTOS的任务优先级设置实现分析
Fix the problem that the AI video intelligent platform easycvr device video cannot be played
[Tikhonov] image super-resolution reconstruction based on Tikhonov regularization
Product learning (III) - demand list