The below question is from made easy test series:
Consider a 32 bit virtual address as follows:
System uses 3 level paging and the bits for the respective levels are as indicated above. Then the size of page table for a process which requires 256 KB of memory statrting at address 0, _____ [Assume entry size = 2B]
Ans: 4608 B
But I am getting 2560 B
My Solution:
Process size = 256KB
Page size = 2$^{8}$ B (From offset field)
No. of pages in the process = No. of entries in P3 = $\frac{256KB} {2^{8}} $ = 2$^{10}$
Size of Page table P3 = 2$^{10}$ x 2 = 2$^{11}$ B
No. of pages in P3 = No. of entries in P2 = $\frac{2^{11}} {2^{8}} $ = 2$^{3}$
Size of Page table P2 = 2$^{3}$ x 2 = 2$^{4}$ B
No. pages in P2 = No. of entries in P1 = $\frac{2^{4}} {2^{8}} $ ~ 1
Thus P1 will require 1 page
P2 will require 1 page
P3 will require 2$^{3}$ pages
Thus total memory required for page table of P across all level= Size of page x No. of pages required for the pages tables = 2$^{8}$ x (2$^{3}$ + 1 + 1) = 2560 B
One more thing I found confusing in the question is 1 page of level 3 can point to 2$^{6}$ pages of process P but if we take into consideration page size and page table entry then each page of every level should point $\frac{2^{8}} {2} $ = 2$^{7}$ pages.
I don't know what I am getting wrong. Please correct me.