Paging

Paging


Recall how for caches we divided memory into blocks, or cache lines. And this’s the granularity at which caching operates. Similarly, for a paging system we divide up our physical address into pages, often 4k long. Pages, are the granularity at which we grant memory to processes. The higher order bytes determine the page number, also called the physical page frame. And the lower order bytes determine the offset into the page. Correspondingly, the virtual address space is similarly divided into pages. Again, lower order bytes determine the offset within a page. The higher ones determine the virtual page number. The number of bytes in the offset always match, that’s because virtual page sizes and physical page sizes aren’t necessarily the same. But, the number of bits involved in the virtual page number need not match the number of bits used to identify the physical frame number. That’s because, as we said before, it’s possible to have more virtual pages than physical pages. Since we’re mapping page for page between virtual and physical addresses, the offsets stay the same. We do need to translate page numbers however. And for this, we use a data structure called the Page Table.