CS代考计算机代写 Carnegie Mellon

Carnegie Mellon
VM as a Tool for Memory Management
 Key idea: each process has its own virtual address space  It can view memory as a simple linear array
 Mapping function scatters addresses through physical memory
 Well chosen mappings simplify memory allocation and management
Address 0 translation
Virtual 0 Address
Space for Process 1:
N-1
0
VP 2
Physical Address Space (DRAM)
(e.g., read-only library code)

PP 2
PP 6
PP 8
VP 1

Virtual Address Space for Process 2:
VP 2
VP 1

N-1
M-1
1

Carnegie Mellon
VM as a Tool for Memory Management  Memory allocation
 Each virtual page can be mapped to any physical page
 A virtual page can be stored in different physical pages at different times  Sharing code and data among processes
 Map virtual pages to the same physical page (here: PP 6)
Virtual 0 Address
Space for Process 1:
N-1
0
Address 0 translation
Physical Address Space (DRAM)
(e.g., read-only library code)

PP 2
PP 6
PP 8
VP 1
VP 2

Virtual Address Space for Process 2:
VP 2
VP 1

N-1
M-1
2

Carnegie Mellon
VM as a Tool for Memory Protection  Extend PTEs with permission bits
 Page fault handler checks these before remapping  If violated, send process SIGSEGV (segmentation fault)
Process i:
VP 0: VP 1: VP 2:
Process j:
VP 0: VP 1: VP 2:
SUP READ
WRITE
• WRITE
Address
Physical Address Space
No
Yes
No
PP 6
No
Yes
Yes
PP 4
Yes
Yes
Yes
PP 2
PP 4
PP 6
SUP READ
Address
PP 2
PP 8
No
Yes
No
PP 9
PP 9
Yes
Yes
Yes
PP 6
PP 11
No
Yes
Yes
PP 11
3