当前位置:网站首页>1265_ Implementation analysis of adding tasks to task ready linked list in FreeRTOS
1265_ Implementation analysis of adding tasks to task ready linked list in FreeRTOS
2022-06-10 01:32:00 【grey_ csdn】
All learning summary : https://github.com/GreyZhang/g_FreeRTOS
Previously, I analyzed how to create a task, stay task Two functions are called at the end of the creation , One of them is used to initialize the task object , The other is to add the initialized task to the task ready list . The previous part of the code has been interpreted , This time, let's see how to add tasks to the task ready list .

The first step in the operation is to enter the critical protection of critical code , This step usually deals with some interrupt information . Interrupt handling for different platforms will vary greatly , This time I just take this opportunity to have a look ARM M3 Kernel MCU How to deal with... In the above section .

After several jumps , The equivalent effect of this function is like this . Inside this , It further calls the interrupt disable interface . Next , Analyze the implementation of this off interrupt interface .

above , It is the original design found after several times of packaging and disassembly . The overall design should be simple , The first step is to assign a temporary variable , The second part assigns a value to a register , The result of the assignment is the value of the temporary variable output from the processing result of the first sentence . Back , It's done again 2 Assembly instructions . here ,configMAX_SYSCALL_INTERRUPT_PRIORITY The expanded value of is 80.
It feels like , Article 1 quality can be directly used C Language implementation . A similar idea , Make a test to see if there is any abnormality in the system .

After the above modification , I still haven't found any problems with my previous engineering test functions .

At least , Now created task There is no exception during the printing operation in . But the parameters here cannot be reduced any more , It is not possible to assign parameters directly . Here we use a parameter that refers to , Its function should be to let the compiler help allocate a transfer register to realize the assignment of a special register .

in the light of BASEPRI, Here's a description . Actually , This is in a special register exception One of the mask registers .

This is a base priority mask register .

If the value of this register is 0 There is no effect when , If it is non-zero , Some interrupts will be masked . This register actually defines exception The lowest priority processed , As long as the priority is numerically equal to this value exception Will not deal with .

This is a directive , It should be easy to understand , Its function should be : Synchronize the command at this position .

This is similar to the instruction synchronization above : Synchronize data at this location .

such , Return to the previous function interface . This interface has previously analyzed the implementation of disabling interrupts , In fact, it shields some priority interrupt processing . After entering this function , First, a counter will be ++ operation . Here is a message to note , At the beginning uxCriticalNesting = 0xaaaaaaaa, instead of 0. This part also needs to test whether the running effect is consistent with my analysis in the code . If the initial value uxCriticalNesting = 0xaaaaaaaa, In fact, during the initial task creation, there is only an interrupt mask . however , Will this affect the number of tasks that can be created during initialization ?
First, make a test of the above questions , See what the value is .

From the above results , This time the analysis path is right . When initializing , The value here is a non-zero value .


Continue with the previous analysis , If there are no ready tasks at present , Then the newly added task is set as the current ready task . If the number of tasks ready this time is 1, This is the first attempt to add information to the ready task list , You also need to initialize the ready task linked list .
If the currently ready task already exists , Let's see if the scheduler is running . If it hasn't run yet , The high priority task is set as the current ready task .

after , Add the task to the task ready list and exit the key protection . Check whether the scheduling is running again , If it doesn't work, it's over . If it runs , Trigger a task preemption process according to the actual configuration .

In preemptive mode , The above task preemption processing runs this code . The implementation is actually a PendSV Request , Trigger a context switch in super permission mode . There is no special need to synchronize the following data and instructions , Just in case .
such , The analysis is basically completed by adding the ready task linked list . There may also be a PendSV The concrete analysis of , This involves some kernel information , Read the document later and then analyze it .
边栏推荐
- 【无标题】416. 分割等和子集
- Never far away, five programming languages that may be doomed to decline
- Locust:微服务性能测试利器
- iNFTnews | 元宇宙进行时:那些跑步入场的互联网大厂在如何谋篇布局?
- Keep alive in TCP connection
- RHCSA第七天
- The calculation of Luogu p1028 number and the introduction to dynamic programming
- What if win11 returns win10 without a return option?
- Random talk on test coverage
- FlinkSQL 之乱序问题
猜你喜欢

Win11退回Win10没有返回选项怎么办?

Practice of Flink CDC + Hudi massive data entering the lake in SF

Rhcsa day 7
[email protected] 项目实训"/>[email protected] 项目实训

Source code analysis of Tencent libco collaboration open source library (I) -- download libco compilation and installation and try to run the sample code

Analyse du code source de la Bibliothèque open source de Tencent libco CO CO - Process

iNFTnews | 元宇宙进行时:那些跑步入场的互联网大厂在如何谋篇布局?

Where should middle-aged test development engineers go? The unknown is tomorrow, break the label

【程序人生】“阶段总结”-不知所措

花了两小时体验IDEA最新史诗皮肤
随机推荐
The calculation of Luogu p1028 number and the introduction to dynamic programming
Why do programmers run away after two years?
MongoDB 开源“可查询加密”系统 Queryable Encryption
Win11怎么直接退回进入桌面?
Unity技术 - 2D项目经验
Regular expression does not contain a string
Analyse du code source de la Bibliothèque open source de Tencent libco CO CO - Process
有机金属多孔材料MOF(Fe)包载喜树碱,藤黄酸、吲哚菁绿|RMOF-3包载紫杉醇定制
The gradient decline triggered a "heated debate" among AI bulls. Netizen: everyone's answer is worth seeing
【ICLR 2022】Towards Continual Knowledge Learning of Language Models
分布式数据库下子查询和 Join 等复杂 SQL 如何实现?
【webrtc】PCF和PC的构建、会话与媒体协商 流程
TCP 连接中的keep-alive
【FPGA】day17-单总线协议ds18b20简介
Beyond compare 3 key serial number sharing and key revocation solutions
Dependent auto assembly
iNFTnews | 元宇宙进行时:那些跑步入场的互联网大厂在如何谋篇布局?
The project was successful, and the project manager was the greatest contributor?
漫谈测试覆盖率
【LeetCode】接雨水