-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path9.html
378 lines (322 loc) · 10.5 KB
/
9.html
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="../static/css/base.css" rel="stylesheet">
<link href="../static/css/tailwind.min.css" rel="stylesheet">
<link href="https://fonts.font.im/css?family=Source+Serif+Pro%7CLato%7CInconsolata" rel="stylesheet"
type="text/css">
<title>CSAPP 讨论会</title>
<!-- browser favicon-->
<link rel="shortcut icon" href="https://cdn-0x4f.do3ob.cn/assets/favicon-gggj2dbz.png">
<style>
.font-sans {
font-family: 'Lato', 'SimHei', 'STHeiti', 'SimHei', 'Serif';
}
.font-serif {
font-family: 'Source Serif Pro', 'Songti SC', 'SimSun', 'Serif', serif;
}
</style>
<link rel="stylesheet" href="../static/katex/katex.min.css">
<script defer src="../static/katex/katex.min.js"></script>
<!-- <script defer src="../static/katex/auto-render.min.js"-->
<!-- integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05"-->
<!-- crossorigin="anonymous"></script>-->
<script defer src="../static/katex/auto-render.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
renderMathInElement(document.body, {
// customised options
// • auto-render specific keys, e.g.:
delimiters: [
{ left: '$$', right: '$$', display: true },
{ left: '$', right: '$', display: false },
{ left: '\\(', right: '\\)', display: false },
{ left: '\\[', right: '\\]', display: true }
],
// • rendering keys, e.g.:
throwOnError: false
});
});
</script>
<link rel="stylesheet" href="../static/reveal/reveal.css">
<link rel="stylesheet" href="../static/reveal/theme/simple.css" id="theme">
<style>
.reveal .slide-number {
font-size: 26px;
border-radius: 5px;
background-color: rgba(0, 0, 0, .3);
}
.reveal .slides {
border: 1.5px #ddd solid;
border-radius: 7px;
text-align: left;
font-weight: 300;
}
.reveal h1,
.reveal h2,
.reveal h3,
.reveal h4 {
font-family: 'Lato', 'SimHei', 'STXihei', 'Sans Serif';
font-weight: 400;
}
.reveal p,
.reveal li,
.reveal center {
font-size: 32px;
font-family: 'Lato', 'STHeiti', 'SimHei', 'Sans Serif';
}
.reveal li+li {
margin-top: 10px;
}
.reveal ul {
display: block;
margin-right: 15px;
}
.reveal p,
.reveal h1,
.reveal h2,
.reveal h3,
.reveal h4,
.reveal h5 {
padding: 0 25px 0 25px;
}
.reveal table {
font-size: 32px;
font-family: 'Lato', 'STHeiti', 'SimHei', 'Sans Serif';
margin-top: 15px;
margin-bottom: 15px;
}
.reveal th {
background-color: #eee;
}
.reveal tr:nth-child(even) {
background-color: #efffff;
}
.reveal h1,
.reveal h2,
.reveal h3,
.reveal h4,
.reveal h5,
.reveal h6 {
text-align: left;
margin: 0 0 20px 0;
color: #222;
font-weight: 400;
line-height: 1.2;
letter-spacing: normal;
}
.reveal h1 {
margin: 0 10 0 10;
font-size: 60px;
}
.reveal .middle h1 {
text-align: center;
}
.reveal h2 {
font-size: 48px;
border-bottom: 2px solid rgb(106, 0, 95);
padding-bottom: 5px;
}
.reveal h3 {
font-size: 1.15em;
}
.reveal h4 {
font-size: 1.05em;
}
.reveal .center {
text-align: center;
}
.reveal .middle {
height: 728px;
display: flex;
align-items: center;
width: 100%;
}
.reveal pre {
font-size: 28px;
background-color: #eee;
border-radius: 3mm;
padding: 10px 10px 10px 10px;
}
.reveal pre code {
max-height: none;
}
.reveal code {
font-family: 'Inconsolata', 'STKaiti', 'KaiTi', 'Sans Serif', Monospace;
}
.reveal .middle blockquote {
text-align: center;
color: rgb(106, 0, 95);
background: none;
box-shadow: none;
}
.reveal .middle blockquote a {
color: inherit;
}
.reveal blockquote p,
.reveal blockquote li {
font-family: 'Lato', 'STKaiti', 'KaiTi', 'Sans Serif';
}
section .center {
display: block;
margin-left: auto;
margin-right: auto;
}
.reveal .author-block {
margin: 75px 0 35px 0;
}
.reveal .author-affiliation img {
margin: 15px 0 0 0;
}
.reveal .author-block p,
.reveal .author-affiliation p {
font-family: 'Kaiti', 'STKaiti', 'Serif', 'Times', 'Times New Roman';
margin-block-start: 0em;
margin-block-end: 0em;
}
.reveal .author-affiliation {
display: inline-block;
font-size: 90%;
}
.reveal hr {
border: 10px solid rgba(0, 0, 0, 0);
}
.reveal li {
margin-top: 10px;
}
</style>
</head>
<body class="d-flex flex-column h-100">
<div class="reveal">
<div class="slides">
<section>
<div class="center middle"><div style="width:100%"><div>
<h1 class=" text-2xl mt-2 font-sans">CSAPP 讨论会</h1>
<p class=" font-serif my-1">Week4 虚拟内存<br/>
2022/12/24</p>
</div>
</div>
</div>
</section>
<section>
<section> <div>
<h2 class=" text-xl mt-2 pb-2 font-sans">虚拟内存页表设计</h2>
<p class=" font-serif my-1">原理是维护一个虚拟内存到物理内存的映射</p>
<ul class=" list-disc font-serif">
<li class=" ml-8">哈希表</li>
<li class=" ml-8">多级固定页表(tree-based address translation)<ul class=" list-disc font-serif">
<li class=" ml-8">建立索引</li>
<li class=" ml-8">建立索引的索引</li>
<li class=" ml-8"><a href="https://www.kernel.org/doc/html/latest/admin-guide/mm/hugetlbpage.html">huge pages</a> (2MB, 1G)</li>
</ul>
</li>
</ul>
<p class=" font-serif my-1">查找过程(P.41)</p>
<ul class=" list-disc font-serif">
<li class=" ml-8">page table walk</li>
</ul>
</div> </section>
<section> <div>
<h2 class=" text-xl mt-2 pb-2 font-sans">cache</h2>
<ul class=" list-disc font-serif">
<li class=" ml-8">TLB</li>
<li class=" ml-8">L1, L2, L3</li>
</ul>
<div class="codehilite"><pre class=" bg-gray-100 overflow-x-auto rounded p-2 mb-2 mt-2"><span/><code>$ cpuid <span class="p">|</span> grep -i cache
</code></pre></div>
<p class=" font-serif my-1"><img alt="" src="./assets/cache.png"/></p>
</div> </section>
<section> <div>
<h2 class=" text-xl mt-2 pb-2 font-sans">TLB 相关问题</h2>
<p class=" font-serif my-1">TLB 会不够用吗?</p>
<ul class=" list-disc font-serif">
<li class=" ml-8">prefetch</li>
<li class=" ml-8">L1 hidden latency </li>
</ul>
<p class=" font-serif my-1">process switch 带来的问题</p>
<ul class=" list-disc font-serif">
<li class=" ml-8">flush TLB</li>
<li class=" ml-8"><a href="https://stackoverflow.com/questions/52813239/how-many-bits-there-are-in-a-tlb-asid-tag-for-intel-processors-and-how-to-handl">tagged TLB(ASID)</a></li>
</ul>
<p class=" font-serif my-1">还有其他问题: cache management, cache coherence .etc</p>
</div> </section>
<section> <div>
<h2 class=" text-xl mt-2 pb-2 font-sans">虚拟内存的用处</h2>
<ul class=" list-disc font-serif">
<li class=" ml-8">物理内存多时: prefetch(投机)</li>
<li class=" ml-8">物理内存少时: swap</li>
<li class=" ml-8">内存保护 (P.18)</li>
<li class=" ml-8">链接和加载更容易 </li>
<li class=" ml-8">按需分配(COW)</li>
<li class=" ml-8">实现 <a href="https://eli.thegreenplace.net/2011/01/27/how-debuggers-work-part-2-breakpoints">watch point</a></li>
</ul>
<div class="codehilite"><pre class=" bg-gray-100 overflow-x-auto rounded p-2 mb-2 mt-2"><span/><code>$ gcc mmap-alloc.c <span class="o">&&</span> ./a.out
</code></pre></div>
</div> </section>
<section> <div>
<h2 class=" text-xl mt-2 pb-2 font-sans">Memory Copy</h2>
<p class=" font-serif my-1">内核与空间交互数据需要进行数据的拷贝
<img alt="" src="./assets/memory_copy.png"/></p>
</div> </section>
<section> <div>
<h2 class=" text-xl mt-2 pb-2 font-sans">Memory-Mapping</h2>
<p class=" font-serif my-1">没有中间商赚差价</p>
<ul class=" list-disc font-serif">
<li class=" ml-8">映射文件</li>
<li class=" ml-8">映射设备<ul class=" list-disc font-serif">
<li class=" ml-8"><a href="https://docs.kernel.org/networking/packet_mmap.html">Packet MMAP</a></li>
</ul>
</li>
<li class=" ml-8">进程间共享内存</li>
</ul>
</div> </section>
</section>
<section>
<div>
<h2 class=" text-xl mt-2 pb-2 font-sans">内存分配</h2>
<ul class=" list-disc font-serif">
<li class=" ml-8">链表</li>
<li class=" ml-8">fixed page pool</li>
<li class=" ml-8">伙伴系统</li>
</ul>
</div>
</section>
<section>
<div>
<h2 class=" text-xl mt-2 pb-2 font-sans">Garbage Collect</h2>
<ul class=" list-disc font-serif">
<li class=" ml-8">reference conuting<ul class=" list-disc font-serif">
<li class=" ml-8">COW</li>
</ul>
</li>
<li class=" ml-8">mark sweep</li>
</ul>
<p class=" font-serif my-1">参考书籍</p>
<ul class=" list-disc font-serif">
<li class=" ml-8"><a href="https://book.douban.com/subject/26821357/">垃圾回收的算法与实现</a></li>
</ul>
</div>
</section>
</div>
</div>
<script src="../static/reveal/reveal.js"></script>
<script>
Reveal.initialize({
width: 1024, height: 768,
slideNumber: 'c/t',
controlsTutorial: false,
progress: false,
hash: true,
center: false,
autoAnimateUnmatched: true,
autoAnimateEasing: 'ease-out',
autoAnimateDuration: 0.3,
transitionSpeed: 'fast'
});
</script>
</body>
</html>