File tree Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 9
9
OS 课缺失的 lecture7 可以看学堂在线公开课的版本
10
10
11
11
## 学习进度
12
+
13
+ 书籍和课程视频
14
+
12
15
|||
13
16
| ---| ---|
14
17
| CSAPP| ch1 |
15
- | computer RISC-V edition| ch1.2 |
16
- | OS Three pieces| ch1 |
17
- | os_lecture| lecture03 |
18
- | 操作系统(RISC-V)(2020秋)| 2.2 从OS角度看RISC-V |
18
+ | 计算机组成与设计 RISC-V edition| ch2.3.2 常数 |
19
+ | OS Three easy pieces| ch4 进程抽象 |
20
+ | rCore Turtorial Book| ch1.6 为内核支持函数调用 |
21
+ | 程序员的自我修养链接装载库| ch1.6 线程 |
22
+ | os_lecture| lecture03 70min |
23
+ | 操作系统(RISC-V)(2020秋)| 3.4 系统调用 |
24
+
25
+ |||
26
+ | ---| ---|
19
27
| MIT 6.828 Operating System Engineering| |
20
28
| xv6 a simple Unix-like teaching operating system| |
21
29
Original file line number Diff line number Diff line change
1
+ # [ volatile 不解决分支预测] ( /2023/08/volatile_and_cpu_branch_prediction.md )
2
+
3
+ 之前看书碰见过 volatile 好几次一直没记笔记,最近看 程序员的自我修养 书中也提到了 volatile 所以得重视起来
4
+
5
+ 根据 ptr::read_volatile 的文档: ` guaranteed to not be elided or reordered by the compiler `
6
+
7
+ 由于 CPU 读写速度远快于内存,所以 CPU 会分支预测某个 if 大概率走 true 分支的时候就会提前执行完 true 分支的指令
8
+
9
+ ## 分支预测导致单例模式要 double check
10
+
11
+ 显然 volatile 只能解决** 编译器优化掉和重排** 并不能干预 CPU 分支预测提前执行
12
+
13
+ 程序员的自我修养 书中说 引入 barrier 函数和 double-check 解决指令重排导致的单例初始化问题
14
+
15
+ ## branch prediction side-channel attack
16
+
17
+ malware(恶意软件) 欺骗 CPU 利用分支预测提前执行的特点 提前读取其他进程的内存数据而不会 SIGSEGV
18
+
19
+ 目前只能通过操作系统来防御这样分支预测的 malware
Original file line number Diff line number Diff line change 1
1
- [ 文章列表 - 吴翱翔的博客] ( / )
2
2
- [ 正在读的书] ( /books.md )
3
3
- ** 2023-08**
4
+ - [ volatile 不解决分支预测] ( /2023/08/volatile_and_cpu_branch_prediction.md )
4
5
- [ qemu vscode gdb] ( /2023/08/qemu_riscv_vscode_gdb.md )
5
6
- [ gcc/ld --as-needed] ( /2023/08/gcc_ld_as_needed.md )
6
7
- [ dumpbin] ( /2023/08/dumpbin_ldd_alternative_on_windows.md )
You can’t perform that action at this time.
0 commit comments