操作系统

Time: 2025-02-20 Thursday 23:56:01
Author: Jackasher

操作系统

读写互斥

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
struct rw_lock{
2 sem_t lock;
3 int reader; // 记录读者线程的数量
4};
5
6void reader_lock(rw_lock* rw)
7{
8 ++reader;
9 if (reader == 1) // 如果是第一个读者线程则需要同写者线程竞争链表使用权限
10 sem_wait(&rw->lock);
11}
12
13void reader_unlock(rw_lock* rw)
14{
15 --reader;
16 if (reader == 0) // 最后一个读者线程使用完毕后唤醒写者线程
17 sem_post(&rw->lock);
18}
19
20void writer_lock(rw_lock* rw)
21{
22 sem_wait(&rw->lock);
23}
24
25void writer_unlock(rw_lock* rw)
26{
27 sem_post(&rw->lock);
28}

虚拟内存

image-20250217040028788

是谁处理内存转换的?(cpu)

image-20250217040438849

image-20250217040404076

image-20250217040306829

为什么要用页表而不是 Base Limit

image-20250217043322294

页表转换

image-20250217045622660

如何解决页表转换太慢

image-20250217045806352

页表模型

image-20250217050054448

Swap

image-20250217052730499

文件读写也是有 Page Cache 的

image-20250217053701957

一切皆文件

image-20250217055015868

image-20250217055032039

jack


操作系统
http://example.com/2025/02/20/操作系统/
作者
Jack Asher
发布于
2025年2月20日
许可协议