Operating System

A bit off topic but I am unable to solve this

Consider a virtual memory system with physical memory of 8GB, a page size of 8KB and 46 bit virtual address. Assume every page table exactly fits into a single page. If page table entry size is 4B then how many levels of page tables would be required.

Hey @anindya-gupta
Page size = 8KB = 2^13 B
Virtual address space size = 2^46 B
PTE = 4B = 2^2 B
Number of pages or number of entries in page table, = (virtual address space size) / (page size) = 2^46B/2^13 B = 2^33

Size of page table,

= (number of entries in page table)*(size of PTE) = 2^33*2^2 B = 2^35 B

To create one more level,

Size of page table > page size Number of page tables in last level, = 2^35 B / 2^13 B = 2^22

Base address of these tables are stored in page table [second last level].

Size of page table [second last level] = 2^22*2^2B = 2^24B

To create one more level,
Size of page table [second last level] > page size

Number of page tables in second last level = 2^24B/2^13 B = 2^11

Base address of these tables are stored in page table [third last level]

Size of page table [third last level] = 2^11*2^2 B = 2^13 B = page size

∴ 3 levels are required.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.