07.03 Virtual Memory Note
Question
Given a 2-level paged virtual memory model
PD Index | PT Index | Offset |
---|---|---|
10 bits | 10 bits | 12 bits |
Also,
PD Entry Size | PT Entry Size |
---|---|
4 bytes | 4 bytes |
Consider a process P:
Start Virtual Address | Start Physical Address |
---|---|
0x12340000H | 0x98760000H |
A page fault occurs when the process P accesses the virtual address (VA) 0x12345678H
. The operating system dynamically allocates physical page frames for the corresponding page directory entry and page table entry as follows:
-
The page directory base address is read from CR3 to calculate the physical address of the page directory entry for this access, and a new page is allocated for this entry to serve as a page table.
-
The physical page frame number of the new page table page is set to
0xABCDEH
. -
In the new page table, the physical page frame number
0x19810H
is allocated for the virtual page number.
Answer the following questions:
-
For the given VA, find the:
-
a. Page Directory Index (PD Index)
-
b. Page Table Index (PT Index)
-
c. Offset within the page
-
-
Find the physical address of the Page Directory Entry (PDE PA) for this access.
-
Find the base physical address of the page table (PT Base PA) and the physical address of the Page Table Entry (PTE PA) for this access.
-
Find the final physical address (PA) that is accessed within the page.
Answer
-
For VA
0x12345678H
:We got
0001 0010 0011 0100 0101 0110 0111 1000
in binary.- a. PD Index:
00 0100 1000 == 0x048H
- b. PT Index:
11 0100 0101 == 0x345H
- c. Offset:
0110 0111 1000 == 0x678H
- a. PD Index:
-
PDE PA:
0x98600000H + 0x048H * 4 == 0x98600120H
-
PT Base PA:
0xABCDEH << 12 == 0xABCDE000H
PTE PA:
0xABCDE000H + 0x345H * 4 == 0xABCDE480H
-
Final PA
0x19810H << 12 + 0x678H == 0x19810678H