5-bit processor (so physical memory of 32 bytes, starting at 0x00 and ending at 0x1F)
page size of 4 bytes (so 8 pages of 4 bytes each)
The outer page table has 4 entries, the inner page table has 8 entries
The outer page table’s values are [3,0,2,1], the inner page table’s values are [3,5,6,0,7,4,1,2]
Write a program that, given a logical address, returns the physical address by looking it up through the two-level page table
Test this with the following inputs and expected outputs:
Tip: it helps to first make a drawing/sketch/schematic of what this looks like before programming
Note: logical addresses will still be 5-bits in length! Think up-front about how the bits should be used!
Extra challenge (optional): add a way to have gaps in your page tables (i.e., for not-yet-allocated pages, so you can simulate page faults to find a new main memory gap and assign that to the page tables dynamically). Track whether a page is already assigned or not using an additional valid/invalid status bit.