retagged by
1,278 views
4 votes
4 votes

The below question is from made easy test series:

Consider a 32 bit virtual address as follows:

       10           8           6          8
        P1          P2         P3      Offset

 

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.

retagged by

1 Answer

0 votes
0 votes

From the question we can calculate the following:

  1. Max number of entries in 1 page = 2^8B/2B = 2^7 entries.
  2. Number of Pages of the Process = 256KB/256B = 2^10 = 1024.
  3. Now each page table should fit into a single frame/page. So if we see the arrangement given for P3 we have 6 bits so we can have 2^6 entries for the page table but we just calculated that one page can hold a max of 2^7 entries, so we can observe that the arrangement given for P3 is not filling up the entire page but only 2^6 entries of the available 2^7 entries.
  4. So for P3 each page is containing 2^6 entries and we have 2^10 pages so for P3 how many pages do we need: 2^10/2^6 = 2^4 = 16.
  5. For P2 we have 2^4 entries which will fit into one page.
  6. For P1 again we need 1 page to refer to P2’s single page.
  7. So total no. of pages needed = 16 + 1 + 1 = 18 and total size of the Page table = 18 * 256B = 4608B.

Try to visualize the question, you will get a better understanding of the flow.

Related questions

0 votes
0 votes
1 answer
2
Markzuck asked Dec 22, 2018
1,327 views
for memory overhead in Multi level paging, for innermost table only 1 page size shall be counted na? and NOT the complete page table size?please explain the concept, than...
0 votes
0 votes
1 answer
3