当前位置:网站首页>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 .
边栏推荐
- Terminology description in the field of software engineering
- ctfshow-web352,353(SSRF)
- The code generator has eliminated the styling of xxxx js as it exceeds the max of 500kb
- Storage function learning notes
- node中引入模块的原理
- Postgraduate entrance examination directory link
- 广发证券开户是安全可靠的么?怎么开广发证券账户
- Is fixed investment fund a high-risk product?
- Product learning (I) - structure diagram
- DC-4靶机
猜你喜欢
随机推荐
Open source! Wenxin large model Ernie tiny lightweight technology, accurate and fast, full effect
[Tikhonov] image super-resolution reconstruction based on Tikhonov regularization
Solve the problem of "unexpected status code 503 service unavailable" when kaniko pushes the image to harbor
代码实战——从零开始搭建自己的Diffusion models/Score-based generative models
ctfshow-web351(SSRF)
K8S搭建Redis集群
MySQL table partition creation method
了解ESP32睡眠模式及其功耗
WiFi settings for raspberry Pie 4
Problem solving: officeexception: failed to start and connect (I)
盘点华为云GaussDB(for Redis)六大秒级能力
图像风格迁移 CycleGAN原理
转行做产品经理,如何挑选产品经理课程?
为什么这么多人转行产品经理?产品经理发展前景如何?
LeetCode+ 71 - 75
运维管理有什么实用的技巧吗
【计网】(一) 集线器、网桥、交换机、路由器等概念
记一次线上接口慢查询问题排查
比赛即实战!中国软件杯发布全新产业创新赛项,校企可联合参赛
开源了!文心大模型ERNIE-Tiny轻量化技术,又准又快,效果全开









