0
votes

I'm studying operating systems and I have a question about page tables.

I came across this question where it asks how the page table size and entry size changes when the size of the page changes. Say the size of a page is reduced from 8KB to 4KB. Now, my guess is that the size of the page table will be doubled, because now the paging system needs twice as more entries to map the pages to frames.

But for the size of the page table entry, I am not so sure. My guess is that the page table entry will be smaller because the physical address it contains is shorter. This is because the physical address is determined by the page/frame size, and if the page size is smaller, the length of the physical address will be 2^-1 shorter as well.

But is this a good assumption? Is the size of the page table entry determined by the length of the address? Or, is the entry size fixed, regardless of the size of each frame/page? I can't seem to find resources / questions specifically regarding the entries.

Thank you!

1
Addresses are typically represented as pointers, and pointers are usually fixed size.el.pescado

1 Answers

2
votes

I'll try to answer to your example, i.e., reducing the page size from 8KB to 4KB. In that case, as you said, the total number of PTEs (page table entries) is indeed doubled, because the number of pages in the virtual address space is doubled.

For the PTE size: the PTE contains several fields, the most important of them is obviously the frame number, which points to the physical address in which the corresponding page lies. Smaller pages also means smaller frames and longer frame numbers, because the number of bits required to represent a frame number is $log2(physical address space size / frame size)$.

So does it mean that we would have larger PTEs? Not necessarily. As many other architectural structures, the PTE size is rounded up to the nearest power-of-two. On x86-64 CPUs, e.g., the PTE size is 64 bits, but only 48--52 of them are actually in use. So adding a few bits (only one in your example) to the frame number field would probably leave the PTE size unchanged.

Edit: you can see the PTE structure in the x86-64 architecture here: https://qph.ec.quoracdn.net/main-qimg-0bcd46d62af1b35820a88f7afc4a50de (taken from https://www.quora.com/How-is-a-page-walk-implemented )