2-Level Page Tables
2-Level Page Tables
Virtual Page Number field in VA: 32 - 12 = 20 bits Number of Virtual Pages: 232 / 212 = 220
VA:
VPN OFFSET
20 bits
VPN 12 bits
Virtual Address
Space of 220 pages
220 -1
2-Level Page Tables
PA:
Page Frame Number field in PA: 38 - 12 = 26 bits Number of Physical Pages: 238 / 212 = 226
PFN OFFSET
26 bits 12 bits
226 -1
1 BYTE
0
1 BYTE
1
0
0
1
220 -1
220 -1
• Break up Page Table into fixed-size blocks of the same size as a page
Do not need to store the entire 2nd level Page Table as a contiguous array
Do not need to store the entire 2nd level Page Table as a contiguous array
Q: What is the actual size of virtual address space being used by the above process?
Each descriptor represents to a 212 = 4KB portion of the address space
2 blocks = 2 x 1024 descriptors imply : 2 x 1024 x 4KB = 8MB address space
Virtual Memory: 2-level Page Table
10 MSBs (bits 22..31) of the virtual address (PTN) are used to index into the Page Table Directory
Next 10 bits (12 ..21) are used to index the chosen Page Table.
0
PTN (10) PN(10) PD(12)
1
2
Page
1023 Offset
(PD)
PTR 0
1
0 2
1
2 1023 4KB Page
0
1
1022 2
1023 Page Tables
1st-Level Page Table 1023
(Page Table Directory)
More Details on Page Table Lookup
26 bits
PTR PTN 00
26 10 2
1st Level Page Table and all blocks of the 2nd-level Page Table are
stored at Page Aligned Boundaries i.e. 12 LSBs are zero
More Details on Page Table Lookup
26 bits
Base Address PN 00
26 10 2
PFN PD
26 12
BYTE
TAG C ACHE INDEX OFFSET
VA PA
CPU PHYSICAL
TLB
CACHE
PA
TLB
VA
CPU
2
Assumes cache block VA = 101 0101 PA = 11 0101
size of w bytes
5
3
VA = 101 1111 PA = 11 1111 15
w BYTES
Virtual Memory and Caches
Virtual Cache
VA = 011 0100
VPN Physical
0
PFN
Memory
1
VA = 011 1110
2
TAG 4
3 0
0
16
4 01101 14
5 3 10101
6 01111
7 10111 4
1
Page Table Process 0
Virtual Cache 14
0 5
1 2
2 15
1
VA = 101 0101
3
4 5
2
5 3
6 VA = 101 1111 15
7
Page Table Process 1
Process 1 will access cached data of Process 0
Virtual Memory and Caches
Virtual Cache
VPN Physical
0
PFN
Memory
1
2
V TAG 4
3 0
0
16
4 I 01101 14
5 3 I 10101
6 I 01111
7 I 10111 4
1
Page Table Process 0
Virtual Cache 14
VPN Physical
0
PFN
Memory
1
2
TAG 4
3 0
PROCESS ID
0
16
4 0 01101 14
5 3 0 10101
6 0 01111
7 0 10111 4
1
Page Table Process 0
Virtual Cache 14
:
Virtual Memory and Caches
Virtual Cache