Search code examples
mipsvirtual-memorypage-tables

Virtual memory: If each page table entry maps one word and requires 4 bytes, how large is the whole page table for a 32-bit machine?


When I try to solve it I get it that the virtual address is 20 bits, thus the amount of entries are 2^20 and each entry holds 1 word, i.e 4 bytes. Hence, 2^20*4 bytes, i.e 4 194 304 bytes ~4 MB is the size of the page table. Correct?


Solution

  • There is missing information: the page size, and page table construction (flat or hierarchical).

    However, assuming a 4k byte page size with flat page tables, then the page number is 20 bits (32-12) as you computed.  (A virtual address is still 32-bits, and a physical address could be the same, smaller, or larger).

    That means that for each process using virtual memory, it would have a 4MB page table, assuming there is a page table entry for every page in the process' virtual address space (not always the case, for example, some MIPS process layouts would give at most only the lower 2GB to a process).