Search code examples
memoryoperating-systemcomputer-sciencepagingvirtual-memory

How to calculate the memory size of a page table for a single process?


In a given system with a 32-bit address space and 4KB page size, the main memory is 16MB. The page table is a single-level page table that is always allocated in the main memory. Each entry in the page table contains a frame number and 4 control bits.

What is the required memory size in megabytes (MB) to store the page table for a single process?

I have tried several calculations by playing with the given sizes and bit numbers. But none of them was helpful.


Solution

  • The physical address space is 16MiB. 16MiB / 4KiB = 4096 = 2^12 pages in physical memory. This means that we need 12 bits to index a physical page. We also have 4 control bits, so in total we need 16 bits = 2 bytes per entry in the page table.

    The virtual address space is 32-bit = 4GiB. 4GiB / 4KiB = 1048576 pages in virtual memory. This means that our single-level page table must have this many entries. Each entry has 2 bytes, so the table will have 2097152 bytes = 2MiB in total.