Paging & Address Translation

the page number and offset

Think of a street address split into two parts: a building number and an apartment number inside that building. 'Building 7, apartment 12' pinpoints exactly one door. A logical address in a paging system is split the very same way. The PAGE NUMBER is the 'building' — which page you are in — and the OFFSET is the 'apartment' — how many bytes from the start of that page. Together they name one exact byte.

Mechanically, the split is done by chopping the bits of the address, not by dividing with arithmetic at run time. If pages are 2^n bytes, the low n bits of a logical address are the OFFSET (a number from 0 to 2^n minus 1, far enough into the page) and the remaining high bits are the PAGE NUMBER (which page). For example, with a 32-bit address and 4 KB pages (2^12), the bottom 12 bits are the offset and the top 20 bits are the page number. The hardware uses the page number to index the page table and read the frame number, then GLUES THE SAME OFFSET BITS unchanged onto the frame number to make the physical address. The offset never changes during translation because a byte sits at the same distance into its frame as into its page — pages and frames are the same size.

This bit-split is why paging is fast and why page sizes are always powers of two: extracting the offset and page number is just masking and shifting bits, with no slow division or multiplication. A frequent beginner error is to think translation 'recomputes' the offset; it does not — only the page-number-to-frame part is looked up, and the offset is carried straight through. If you ever see a page size that is not a power of two, be suspicious; the whole scheme relies on that.

32-bit logical address with 4 KB pages: the address 0x00001ABC in binary splits as page number = top 20 bits = 0x00001 = 1, offset = bottom 12 bits = 0xABC = 2748. The hardware looks up page 1 to find its frame, then keeps offset 2748 unchanged in the physical address.

Splitting a logical address by bits: high bits index the page table, low bits pass through as the offset.

The offset is carried through translation UNCHANGED; only the page number is mapped to a frame. Page sizes are always powers of two precisely so this split is pure bit masking, not slow division.

Also called
page numberpage offset頁號頁內偏移頁面位移