Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
educg-net-22022-2210132
proj292-XUPT-SwardArtOnline-10
Commits
7b71a54d
Commit
7b71a54d
authored
11 months ago
by
你宁可空转也不愿被我抢占
Browse files
Options
Download
Patches
Plain Diff
[Doc]添加RT-Patch相关理论调研
parent
230ea185
main
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/RT-Patch理论依据.md
+67
-0
doc/RT-Patch理论依据.md
doc/RT-Patch理论学习.pdf
+0
-0
doc/RT-Patch理论学习.pdf
with
67 additions
and
0 deletions
+67
-0
doc/RT-Patch理论依据.md
0 → 100644
+
67
−
0
View file @
7b71a54d
```
ad-summary
相关文章:
[如何给嵌入式Linux打实时补丁? - 知乎](https://zhuanlan.zhihu.com/p/118678888)
[“零”智享丨Preempt-RT实时patch介绍 - 知乎](https://zhuanlan.zhihu.com/p/586668309)
RT-Patch链接:
[realtime:preempt\_rt\_versions \[Wiki\]](https://wiki.linuxfoundation.org/realtime/preempt_rt_versions)
```
## 1. 传统Linux
标准的Linux并不是硬时操作系统,因为以下四类区间中只有一类支持[[抢占调度]]
-
[[中断]] x
-
[[软中断]] x
-
进程上下文的[[spinlock]] x
-
**进程上下文的其他区域**
,只有这里支持抢占调度! √
![[Pasted image 20231108222741.png]]
-
T3时刻系统唤醒了高优先级的RT task,但由于此时系统处于不可调度区域,所以RT task无法立即运行
-
T5时刻,中断都结束,但spin lock仍然没有释放,系统仍然处于不可调度区域
-
T6时刻,spin lock释放,高优先级的RT task立马得到调度
从T1到T6,这个区间的时间是不可预测的,所以通用的Linux系统无法达到硬实时的标准。
## 2. RT-patch改进
> 两种思路:
> 1. [[双内核法]]
> 2. **修改内核代码**:通过打补丁的方式,对内核的进程调度、中断服务程序等代码进行修改与优化,提高系统的实时性能,最出名的就是Preempt-RT补丁
```
ad-abstract
原理:
最小化内核中不可抢占部分的代码,同时将为支持抢占性必须要修改的代码量最小化。对[[临界区]]、[[中断处理函数]]等代码进行抢占改进
```
1.
重新实现rt_mutex使内核里的spinlock可被抢占。以前被spinlock_t和rwlock_t保护的临界区现在变得可以被抢占:[[临界区抢占]]
2.
中断线程化:Preempt-RT在内核线程上下文中处理中断:[[中断处理线程化]]
3.
为内核里的自旋锁(spinlock)和信号量(semaphore)实现
[
[优先级继承]
](
PI-Priority
Inheritance)
## 3. 打入RT-patch方法
```
shell
gnuzip patch-xxx-rt-xx
patch
-p1
< patch-xxx-rt-xx
```
[[编译内核]]的时候在[[menuconfig]]中的Preemption Model选择Fully Preemptible Kernel
## 4. 测试方法
可以使用[[cyclictest]]工具进行测试,如果要上压力就用[[stress]]工具
## 5.总结
-
**抢占调度**
**区域:**
1.
中断
2.
软中断
3.
进程上下文的spinlock
4.
进程上下文的其他区域
一般server仅在
**4. 进程上下文的其他区域**
支持抢占
-
**优化方向**
1.
中断线程化(内核线程)
2.
spinlock临界区抢占(拥锁进程优先级继承)
3.
硬件(如Cortex R系列)
---
[[RealTime实时补丁Patch优化原理(理论)]]
This diff is collapsed.
Click to expand it.
doc/RT-Patch理论学习.pdf
0 → 100755
+
0
−
0
View file @
7b71a54d
File added
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets