Download presentation
Presentation is loading. Please wait.
Published byDerick Sherman Edwards Modified over 8 years ago
1
1 Recitation #9, Section F, 15-213, Sp 06 Virtual memory Reminders: Quiz today: virtual memory Shell Lab due Thursday TA: Jernej Barbic Modified from: Kun Gao’s and Minglong Shao’s recitations, Spring 2005, Fall 2004
2
2 Virtual memory One of the most important concepts in CS Benefits of virtual memory (VM): Use RAM as a cache for disk Easier memory management Simplifies linking and loading Access protection Share memory efficiently
3
3 Virtual memory CPU 0: 1: N-1: Memory 0: 1: P-1: Page Table Disk Virtual Addresses Physical Addresses Page hit: page is in memory Page fault: page is on disk Per Process:
4
4 Virtual and physical addresses virtual page number (VPN)page offset virtual address physical page number (PPN) page offset physical address 0p–1 address translation pm–1 n–1 0p–1p Virtual Memory: up to 2 n -1 bytes Physical Memory: up to 2 m -1 bytes
5
5 Page Table translates VPN to PPN Separate page table per each process VPN is the index into the page table
6
6 Translation Lookaside Buffer (TLB) Page table is in memory or even on disk (slow access) TLB keeps things manageable TLB Cache/Memory 1. VA4. PA MMU/ Translation 2. VPN3. PTE 5. Data CPU
7
7 TLB and the L1-Cache virtual address virtual page numberpage offset physical address n–10p–1p validphysical page numbertag validtagdata = cache hit tagbyte offset index = TLB hit TLB L1-Cache...
8
8 Worst case? (most delay)? TLB miss, page fault on page table, then page fault on memory read TLB Cache/Memory 1. VA 3. PTEA (PTBR + VPN) MMU/ Translation 2. VPN 6. Data CPU 4. PTE 5. PA DISK Page Fault/ Page Table Page Fault/ Mem Read
9
9 Example 20-bit virtual addresses 18-bit physical addresses Page size is 1024 bytes TLB is 2-way associative with 16 total entries
10
10 Part 1 A. Virtual address B. Physical address 161514131211109876543171821019 VPN VPO TLBTTLBI 16151413121110987654317210 PPN PPO
11
11 Example: TLB and page table
12
12 Part 2 Virtual address 0x78E6 A. 078E6 = B. Address translation C. Physical address parameterValueParameterValue VPN0x01ETLB hit?N TLB Index0x6Page fault?N TLB Tag0x03PPN0x57 0000 0111 1000 1110 0110 01 0101 1100 1110 0110
13
13 Part 2 Virtual address 0x04AA4 A. 04AA4 = 0000 0100 1010 1010 0100 B. Address translation C. Physical address 01 1010 0010 1010 0100 parameterValueParameterValue VPN0x012TLB hit?Y TLB Index0x2Page fault?N TLB Tag0x02PPN0x68
14
14 Further material Section 10.6.4: a concrete example Read carefully and solve practice problem 10.4
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.