memory requirement of page table


Basic knowledge

  • 1 byte = 8 bits
  • 1 KB = 1024 bytes = (2^{10}) bytes
  • 1 MB = 1024 KB = (2^{20}) bytes
  • 1 GB = 1024 MB = (2^{30}) bytes
  • 1 TB = 1024 GB = (2^{40}) bytes
  • 1 PB = 1024 TB = (2^{50}) bytes

64-bit Logical Address Space

In this environment, every memory address can be 64 bits long. Assuming Page size is 4KB = (2^{12}) bytes.

First, we need to figure out the page offset. Page offset = (log_2(2^{12})) = 12 bits; 12-bits offset is used to access a specific address inside the 4KB range of addresses. 4KB = (2^{12}), so we need only 12-bits for the offset

Therefore, page table has (2^{64-12} = 2^{52}) entries. Suppose each entry in the page table is 4 Bytes, then

For single level page table, memory required is :

  • (2^{50} times 4 times 4) Bytes = (2^{54}) Bytes = (2^{14}) TB = 16 PB

For two level page table, we need first level page table and 1 of (2^{10}) page tables in second level.

  • 1st level size = (2^{42} times 4) bytes = (2^{44}) bytes
  • 2nd level: we only need one among (2^{10}) page tables, so the size = (2^{10} times 4) = 4KB
  • Total = 1st + 2nd = (2^{44}) bytes + 4KB = 16TB + 4KB

Comparing to single level page table, two level page table saves three magnitudes of memory.


# OS
 

本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!