All problems
Page Table Walk Levels
Problem
Compute how many page-table levels are needed for an address space.
virtual_bits is the width of a virtual address, offset_bits is the page-offset width, and entry_bits is how many address bits each table level translates. Each level covers entry_bits bits and the top level covers whatever remains.
Return the number of levels needed (0 when the offset already covers the address).
Hint
Round the remaining virtual bits up to a whole number of table levels.
Test cases
case 1
in: [32,12,10]
expected: 2
case 2
in: [48,12,9]
expected: 4
case 3
in: [32,12,20]
expected: 1
case 4
in: [32,32,10]
expected: 0
Starter codePython
def page_table_levels(virtual_bits, offset_bits, entry_bits):
# Your code here
pass4 test cases · run your code against them in the editor