Search code examples
operating-systemsizememory-addressvirtual-address-spacepage-tables

Determine addresses and page table size


I know that this question has been asked many times but I still feel I struggle with it.

Given: 
physical memory: 2^20
32-bit system
page size: 2^10

I need to determine what a physical and virtual addresses would look like as well as calculate the page table size.

I am not sure what I have is correct but this is what I have got so far:

->Virtual address would look like (22 bits specifying page #)(10 bit specifying offset)
->Physical address would look like** (10 bits specifying frame #)(10 bits specifying offset)

The number of page entries is 2^20/2^10=2^10

How do I calculate the page table size? I am confused since each PTE has both virtual and physical addresses. Would it be number of page entries*(physical address+virtual address)? How would it be different if I have the present bit set?


Solution

  • Size of page table depends on what metadata bits you hold for each entry (valid dirty, etc..)

    Basically the size would be: (num_of_pages)*(num_of_bits_for_frame_number + meta_bits). Ex. (valid bit): 2^22*(10 + 1)