memoryoperating-systempagingramvirtual-memory

How is the physical address of the page table calculated from page directory


I'm trying to understand paging and one thing that messes up my brain is how you can find the page table. Every resource says that the page directory contains a pointer to the page table, but how exactly. As far as I understood the page directory entry holds only 20 Bits of the Page Table Address, so where do the 12 bits for the full Page Table Address come from. Since the next index of the Page Table is 10 bits, we still need 2 bits.

Please care, I'm asking about the address of the Page Table from Page Directory, not the Address of the Page.

Edit: So I mean how to complete this formula: Physical Address of Page Table = Page Directory Entry (20 Bits) + Index from Virtual Address (10 Bits)


Solution

  • The last 2 bits are not needed. If a page table entry is 32 bits, it actually occupies 4 bytes in RAM - so it spans 4 addresses. Those addresses differ on those last 2 bits, and all four combinations of those bits (00, 01, 10, 11) are used.

    Note, that you are using an unusual naming. The term "page table" usually refers to the entire 4kB structure. A single 32 bit record is called "page table entry" instead.