Update 计算机操作系统 - 概述.md

重新绘制配图。
This commit is contained in:
CyC2018
2026-10-26 22:04:13 +08:00
parent 80462f13c6
commit 0a3fae9f5b
5 changed files with 134 additions and 2 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

+2 -2
View File
@@ -78,7 +78,7 @@
如果一个进程在用户态需要使用内核态的功能,就进行系统调用从而陷入内核,由操作系统代为完成。
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/tGPV0.png" width="600"/> </div><br>
<div align="center"> <img src="pics/os-syscall.png" width="740px"/> </div><br>
Linux 的系统调用主要有以下这些:
@@ -107,7 +107,7 @@ Linux 的系统调用主要有以下这些:
因为需要频繁地在用户态和核心态之间进行切换,所以会有一定的性能损失。
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/2_14_microkernelArchitecture.jpg"/> </div><br>
<div align="center"> <img src="pics/os-kernels.png" width="760px"/> </div><br>
## 中断分类
+73
View File
@@ -0,0 +1,73 @@
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="300" viewBox="0 0 760 300">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="380" y="28" class="title">宏内核与微内核</text>
<text x="200" y="56" class="c b">宏内核(Linux)</text>
<rect x="30" y="66" width="340" height="70" rx="6" fill="#C6ECE9" fill-opacity="0.25"/>
<rect x="30" y="146" width="340" height="90" rx="6" fill="#C6E4FB" fill-opacity="0.25"/>
<text x="38" y="82" class="sub">用户态</text>
<text x="38" y="162" class="sub">内核态</text>
<rect x="40" y="88" width="320" height="36" rx="6" fill="#FFFFFF" stroke="#BBBBBB"/>
<text x="200" y="110.5" class="c sub">应用程序</text>
<rect x="40" y="168" width="100" height="28" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="90" y="186.5" class="c sub">文件系统</text>
<rect x="148" y="168" width="100" height="28" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="198" y="186.5" class="c sub">设备驱动</text>
<rect x="256" y="168" width="100" height="28" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="306" y="186.5" class="c sub">内存管理</text>
<rect x="40" y="202" width="100" height="28" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="90" y="220.5" class="c sub">进程调度</text>
<rect x="148" y="202" width="100" height="28" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="198" y="220.5" class="c sub">进程间通信</text>
<rect x="30" y="246" width="340" height="26" rx="6" fill="#EAE9E7" stroke="#BFBEBA"/>
<text x="200" y="263.5" class="c sub">硬件</text>
<text x="570" y="56" class="c b">微内核(Minix、QNX)</text>
<rect x="400" y="66" width="340" height="70" rx="6" fill="#C6ECE9" fill-opacity="0.25"/>
<rect x="400" y="146" width="340" height="90" rx="6" fill="#C6E4FB" fill-opacity="0.25"/>
<text x="408" y="82" class="sub">用户态</text>
<text x="408" y="162" class="sub">内核态</text>
<rect x="410" y="88" width="100" height="36" rx="6" fill="#FFFFFF" stroke="#BBBBBB"/>
<text x="460" y="110.5" class="c sub">应用程序</text>
<rect x="520" y="88" width="100" height="36" rx="6" fill="#E6E3FA" stroke="#B8B0DE"/>
<text x="570" y="110.5" class="c sub">文件系统</text>
<rect x="630" y="88" width="100" height="36" rx="6" fill="#E6E3FA" stroke="#B8B0DE"/>
<text x="680" y="110.5" class="c sub">设备驱动</text>
<rect x="410" y="168" width="100" height="28" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="460" y="186.5" class="c sub">内存管理</text>
<rect x="518" y="168" width="100" height="28" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="568" y="186.5" class="c sub">进程调度</text>
<rect x="626" y="168" width="100" height="28" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="676" y="186.5" class="c sub">进程间通信</text>
<rect x="400" y="246" width="340" height="26" rx="6" fill="#EAE9E7" stroke="#BFBEBA"/>
<text x="570" y="263.5" class="c sub">硬件</text>
<text x="30" y="292" class="sub">微内核把文件系统、驱动等移到用户态,通过消息与内核通信:一个驱动崩溃不会拖垮整个系统,但每次请求多了几次用户态和内核态的切换。</text>
</svg>

After

Width:  |  Height:  |  Size: 4.6 KiB

+59
View File
@@ -0,0 +1,59 @@
<svg xmlns="http://www.w3.org/2000/svg" width="740" height="300" viewBox="0 0 740 300">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="370" y="28" class="title">系统调用:open() 从用户态进入内核态</text>
<rect x="20" y="50" width="700" height="90" rx="6" fill="#C6ECE9" fill-opacity="0.25"/>
<rect x="20" y="160" width="700" height="110" rx="6" fill="#C6E4FB" fill-opacity="0.25"/>
<text x="36" y="70" class="sub b" style="fill:#444">用户态</text>
<text x="36" y="180" class="sub b" style="fill:#444">内核态</text>
<rect x="70" y="80" width="220" height="46" rx="5" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
<line x1="70" y1="94" x2="290" y2="94" stroke="#BBBBBB" stroke-width="1"/>
<circle cx="79" cy="87" r="2.2" fill="#BBBBBB"/>
<circle cx="87" cy="87" r="2.2" fill="#BBBBBB"/>
<circle cx="95" cy="87" r="2.2" fill="#BBBBBB"/>
<text x="79" y="110" class="sub mono">fd = open("a.txt", O_RDONLY);</text>
<rect x="330" y="82" width="180" height="40" rx="6" fill="#FFFFFF" stroke="#BBBBBB"/>
<text x="420" y="106.5" class="c sub">C 库的 open 包装函数</text>
<line x1="292" y1="102" x2="326" y2="102" class="arrow "/>
<rect x="330" y="190" width="180" height="40" rx="6" fill="#EAE9E7" stroke="#BFBEBA"/>
<text x="420" y="206" class="c sub b" style="fill:#444">系统调用表</text>
<text x="420" y="222" class="c sub">按系统调用号查找</text>
<rect x="550" y="190" width="150" height="40" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="625" y="214.5" class="c sub b">内核的 open 实现</text>
<line x1="420" y1="124" x2="420" y2="186" class="arrow "/>
<text x="410" y="150" class="sub e">系统调用号放进寄存器,</text>
<text x="410" y="166" class="sub e">执行陷入指令(x86-64 上是 syscall)</text>
<line x1="512" y1="210" x2="546" y2="210" class="arrow "/>
<path d="M625,188 C625,110 600,90 514,96" class="arrow dash"/>
<text x="632" y="140" class="sub">返回文件描述符</text>
<text x="30" y="290" class="sub">进入内核时 CPU 切换到特权级,执行完再切回用户态。这一来一回比普通函数调用慢得多,所以频繁的小读写要用缓冲区合并。</text>
</svg>

After

Width:  |  Height:  |  Size: 3.6 KiB