Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

07.03 Virtual Memory Note

Question

Given a 2-level paged virtual memory model

PD IndexPT IndexOffset
10 bits10 bits12 bits

Also,

PD Entry SizePT Entry Size
4 bytes4 bytes

Consider a process P:

Start Virtual AddressStart Physical Address
0x12340000H0x98760000H

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

  1. 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
  2. PDE PA:

    0x98600000H + 0x048H * 4 == 0x98600120H

  3. PT Base PA:

    0xABCDEH << 12 == 0xABCDE000H

    PTE PA:

    0xABCDE000H + 0x345H * 4 == 0xABCDE480H

  4. Final PA

    0x19810H << 12 + 0x678H == 0x19810678H