virtual Memory
1 Virtual Memory
Outline Multilevel page tables Different points of view Pentium/Linux Memory System Memory Mapping Suggested reading: 10.6, 10.3, 10.7, 10.8
2 Outline • Multilevel page tables • Different points of view • Pentium/Linux Memory System • Memory Mapping • Suggested reading: 10.6, 10.3, 10.7, 10.8
10.6 Address translation 10.6.3 Multi Level Page Tables
3 10.6 Address Translation 10.6.3 Multi Level Page Tables
Multi-Level Page Tables Given: 4B (212) page size 32-bit address space 4-byte pte Problem: Would need a 4 mb page table ·220*4 bytes
4 Multi-Level Page Tables • Given: – 4KB (212) page size – 32-bit address space – 4-byte PTE • Problem: – Would need a 4 MB page table! • 220 *4 bytes
Multi-Level Page Tables Level 2 Common solution Tables multi-level page tables e.g., 2-level table(P6) Level 1 Table Level 1 table: 1024 entries each of which points fo a Level 2 page table Level 2 table: 1024 entries each of which points to a page
5 Multi-Level Page Tables • Common solution – multi-level page tables – e.g., 2-level table (P6) • Level 1 table: 1024 entries, each of which points to a Level 2 page table. • Level 2 table: 1024 entries, each of which points to a page Level 1 Table ... Level 2 Tables
Multi-Level Page Tables Level 2 Virtual Page Table Page T ables Memory VP O PTE O I O vF1023 PTE 2Ka晶 ocated VM pages vF1024 for code and data PTE2(null) PTE 1023 PTE 3(null) vP2047 PTE 4(null) 匚PTE0 PTE 5(null) PTE 6(null) PTE 1023 PTE 7(null) gap 6K unallocated VM pages PTE 8 1023nu (1K-9) PTES null PTEs PTE 1023 unallocated 1023 unaLlocated pages aaes vP9215 1 lOcated vM page Figure 10. 18 P710 for the stack
6 Multi-Level Page Tables Figure 10.18 P710
Multi-Level Page Tables VIRTUAL ADDRESS n-1 P VPN 1 VPN 2 VPN K VPO Level 1 Level 2 Level k Page Table Page Table Page Table PPN PPO PHYSICAL ADDRESS Figure 10. 19 P711
7 Multi-Level Page Tables Figure 10.19 P711
Representation of virtual Address Space P=1.M=1 Page 15 PT3|P=0,M=0 Page 14 P=1.M=1 P=0.M=1 Page 13 Page Directory Page 12 P=1,M=1 P=1,M=1 Pt P=0,M=0 Page 11 P=1,M=1 P=1.M=1 P=0.M=0 P=0.M=1 P=0,M=1 P=0.M=1 PTO Page 8 P=0.M=1 Page 7 P=0.M=0 P=0,M=0 Page 6 Simplified Example Page 4 Mem Addr 16 page virtual address space age 3 e Disk addr Flags In mem P: Is entry in physical memory? Page 1 On Disk M: Has this part of va space been Page o mapped? Unmapped
8 • Simplified Example – 16 page virtual address space • Flags – P: Is entry in physical memory? – M: Has this part of VA space been mapped? Page Directory PT 3 P=1, M=1 P=1, M=1 P=0, M=0 P=0, M=1 • • • • P=1, M=1 P=0, M=0 P=1, M=1 P=0, M=1 • • • • P=1, M=1 P=0, M=0 P=1, M=1 P=0, M=1 • • • • P=0, M=1 P=0, M=1 P=0, M=0 P=0, M=0 • • • • PT 2 PT 0 Page 0 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 Page 9 Page 10 Page 11 Page 12 Page 13 Page 14 Page 15 Mem Addr Disk Addr In Mem On Disk Unmapped Representation of Virtual Address Space
10.4 VM as a Tool for Memory Management
9 10.4 VM as a Tool for Memory Management
A Tool for Memory Management Separate virtual address space Each process has its own virtual address space Simplify linking sharing loading, and memory allocation
10 A Tool for Memory Management • Separate virtual address space – Each process has its own virtual address space • Simplify linking, sharing, loading, and memory allocation