-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathvirtual_memory.theory.txt
44 lines (37 loc) · 1.99 KB
/
virtual_memory.theory.txt
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
┏━━━━━━━━━━━━━━━━━━━━┓
┃ VIRTUAL_MEMORY ┃
┗━━━━━━━━━━━━━━━━━━━━┛
Virtual memory:
- the memory addresses shown to a program are not the hardware one, but an abstraction of it
- abstraction allows:
- using several hardware sources, "paging"
- sharing same hardware addresses to several programs
- handled by OS, helped by MMU (Memory Management Unit)
Paging:
- i.e. main memory (e.g. RAM) first, auxiliary (e.g. disk) then
- [memory|virtual] page: block of virtual memory
- page frame: block of physical memory
Page table:
- map between pages and their corresponding page frames
- page table entry: entry in page table for a given page
- multi-level paging: paging the page table
- TLB ("Translation Lookaside Buffer"): cache of the page table
Page fault:
- "minor": accessing a page stored in main memory, but not present in page table
- e.g. other programs have loaded page in main memory, but current program did not
- "major": accessing a page stored in auxiliary memory
- induces paging|swapping, i.e. move page from auxiliary to main memory
- "invalid": wrong address error, firing segmentation fault
- e.g. writing to read-only memory, null pointer dereference, buffer overflow, stack overflow
- trashing: too frequent paging, due to not enough pages or not enough virtual memory
Fragmentation:
- pages not fully used, i.e. bigger than their content
Page size:
- usually 4KB
- bigger page size:
- allow page table faster lookup because: smaller page table, and more TLB hits
- increase fragmentation
- increase possibility of trashing
- work best with bigger memory objects, least with small memory objects
- "huge page size": special mode with very big page size, e.g. when working with huge files
- "PSE": x86 instruction for 4MB pages