Introduction
Paging removes external fragmentation by giving up contiguity. The logical address space of a process is cut into fixed-size pages, physical memory into frames of the same size, and any page can sit in any free frame. A per-process page table records which frame holds each page, and the hardware consults it on every memory reference.
Paging costs two things: memory for the page tables, and time, because a reference now needs the page table as well as the data. The first cost leads to multilevel, hashed and inverted page tables; the second leads to the translation look-aside buffer (TLB).
Address translation, page-table entries, page-table size, multilevel and inverted tables, the TLB and effective access time, shared pages, and the internal fragmentation that paging keeps are the standard facts. Virtual Memory and Demand Paging builds on it by letting pages live on disk.
Prerequisites
- Contiguous Memory Allocation and Fragmentation: relocation and limit registers, and the external fragmentation that paging removes.
- Memory Hierarchy and Performance: hit ratio and access-time averaging, used for the TLB.
Core concepts
Address split
With page size bytes and a logical address of bits, the low bits are the offset and the high bits the page number:
where is the frame number found in entry of the page table. Because is a power of 2, the split is just a choice of bits, and the offset is copied unchanged into the physical address. The number of pages is ; with physical address bits the number of frames is and a frame number needs bits.
Page-table entry
| Field | Meaning |
|---|---|
| Frame number | bits |
| Valid (present) bit | The page belongs to the process (and, with virtual memory, is in memory) |
| Protection bits | Read, write, execute permissions; a violation traps |
| Dirty (modified) bit | Set by hardware on a write; a clean page need not be written back when evicted |
| Referenced (accessed) bit | Set by hardware on any access; used by page-replacement approximations |
| Cache-disable bit | For memory-mapped device registers |
The page table itself is in main memory. The page-table base register (PTBR) points to it, so a context switch changes only one register (plus the TLB state). A page-table length register (PTLR) may bound the number of valid pages.
The TLB
The TLB is a small, fast, fully associative (or set-associative) cache of recent page-to-frame translations, typically tens to a few thousand entries. On a TLB hit the frame number comes from the TLB; on a miss the page table is read from memory and the translation is loaded into the TLB, replacing an entry. The associative lookup hardware is covered with cache organisation in Cache Mapping: Direct, Associative and Set-Associative.
A TLB entry belongs to one address space. On a context switch the OS either flushes the TLB or the entries carry an address-space identifier (ASID), so that entries of several processes can coexist. TLB reach is the memory a full TLB maps: entries times page size, for example .
How translation works

- Split the logical address into and .
- Search the TLB for . On a hit, take from the TLB and go to step 5.
- On a miss, read entry of the page table at PTBR (entry size). If the valid bit is 0, trap (an invalid reference, or a page fault under virtual memory).
- Check the protection bits, then load into the TLB.
- Form the physical address and access memory.
The protection check applies on hits as well: TLB entries carry the protection bits.
A hexadecimal translation
With 4 KB pages, the logical address 0x23A7C has offset 0xA7C (the last three hex digits) and page number 0x23 (35). If page 35 is in frame 0x1F4, the physical address is 0x1F4A7C. With hexadecimal addresses and pages of bytes, the offset is always the last three hex digits.
Page-table structures
Single-level size
The page table has one entry per page:
with the entry size. For a 32-bit logical address, 4 KB pages () and bytes: entries, 4 MB per process, which must be contiguous in memory. With 1 GB of physical memory (), the frame number takes 18 bits; adding valid, dirty, referenced and three protection bits gives 24 bits, so 3 bytes would do, and the entry is usually rounded up to 4 bytes.
Multilevel (hierarchical) page tables
Page the page table itself. With entry size , one page holds entries, so each level resolves bits of the page number. The number of levels is
When the division is not exact, the outermost table is the partly filled one.
| Logical address | Page size | Entry size | Bits per level | Page-number bits | Levels |
|---|---|---|---|---|---|
| 32 bits | 4 KB | 4 B | 10 | 20 | 2 (10, 10) |
| 40 bits | 4 KB | 4 B | 10 | 28 | 3 (outer 8, then 10, 10) |
| 46 bits | 8 KB | 4 B | 11 | 33 | 3 (11, 11, 11) |
| 48 bits | 4 KB | 8 B | 9 | 36 | 4 (9, 9, 9, 9) |
In the 40-bit case the outer table has entries, which occupy 1 KB, a quarter of a page. The 48-bit, 4 KB, 8-byte case is the four-level layout of x86-64.
Two-level walk. For a 32-bit address with the 10, 10, 12 split, the logical address 0x00403004 has outer index , inner index and offset 0x004. If entry 1 of the outer table points to the inner table in frame 0x52, and entry 3 of that inner table holds frame 0x2A1, the physical address is 0x2A1004.

Why multilevel saves memory. Only the inner tables that map used pages need to exist. A process with 16 MB of code and data at the bottom of a 32-bit space and a 4 MB stack at the top needs four inner tables for the bottom (each maps 4 MB), one for the stack and one outer table: 6 pages, 24 KB, instead of the 4 MB single-level table. If every page were mapped, the two-level layout would use pages, slightly more than one level.
Cost of a walk. A -level table needs memory reads to find the frame on a TLB miss, then one more for the data: accesses in all.
Hashed page tables
For large address spaces the page number is hashed into a table whose entries are chains of (page number, frame, next) elements. A lookup hashes and walks the chain. Hashed tables suit sparse 64-bit address spaces; a variant, the clustered page table, maps several consecutive pages per element.
Inverted page tables
An inverted page table has one entry per physical frame, holding the (process id, page number) that occupies it. There is one table for the whole system, and its size depends on physical memory, not on the address spaces.
- Physical memory of 4 GB with 4 KB frames gives entries. With 48-bit logical addresses the page number has 36 bits; with a 12-bit process id an entry needs 48 bits = 6 bytes, so the table is 6 MB for the whole machine.
- A conventional single-level table for the same 48-bit space with 8-byte entries would need bytes = 512 GB per process.
- The cost is lookup time: the table is indexed by frame, so finding a page means searching it. A hash table on (pid, page) cuts the search, at the price of one more memory access, and the TLB is consulted first.
- Shared pages are awkward, because each frame records only one (pid, page) pair.
Shared pages
Reentrant (read-only, non-self-modifying) code can be shared: the page tables of several processes point to the same frames. Forty users running an editor with 150 KB of code and 50 KB of private data each need KB without sharing and KB with it.
Mathematical explanation: effective access time
Let be the memory access time, the TLB lookup time, the TLB hit ratio and the number of page-table levels. With a sequential lookup (TLB first, page-table memory reads only after a TLB miss; the final data access follows on either path):
State which convention a question uses. Three conventions are in use:
- TLB time counted, data access counted (the formula above). This is the effective memory-access time.
- TLB time neglected (): .
- Translation time only, without the data access that follows: . Some questions ask "the average time to translate an address"; that excludes the final memory access.
Example. ns, ns, , single-level table ():
- full access: ns;
- TLB time neglected: ns;
- translation only: ns;
- without any TLB every access costs ns, so the TLB saves 70 ns per access under the first convention.
With a two-level table () the miss path costs ns and the EAT becomes ns.
Required hit ratio. For the single-level case to reach 125 ns: , so .
Internal fragmentation and page size
A process of bytes needs frames, and the last one is partly empty. A 50,000-byte process with 4 KB pages needs 13 frames (12 full pages hold 49,152 bytes), and the last frame wastes bytes. On average the waste is about half a page per process.
Related material. Tanenbaum (3.5.3) balances the two costs of page size. With average process size and entry size , the overhead per process is for the page table plus for internal fragmentation, which is minimised at . For MB and bytes that gives 4 KB.
Worked examples
Translation with a page table
Pages of 4 KB, page table: page 0 in frame 5, page 1 in frame 2, page 2 invalid, page 3 in frame 7, page 4 in frame 9.
| Logical address | Page, offset | Result |
|---|---|---|
| 13,000 | 3, 712 | |
| 1,000 | 0, 1,000 | |
| 9,000 | 2, 808 | trap: page 2 invalid |
| 17,000 | 4, 616 |
Sizing a three-level table
46-bit logical addresses, 8 KB pages and 4-byte entries: the offset takes 13 bits, leaving 33 bits of page number. One page holds entries, so each level resolves 11 bits and levels are needed. A TLB miss then costs 3 page-table reads plus the data access.
Choosing the page size so that every level fits in one page
32-bit logical addresses and 4-byte entries. What is the smallest page size for which a two-level table works with every table, outer and inner, fitting in one page? And for three levels?
With an offset of bits, a page holds entries, so each level can resolve at most bits. The page number has bits, and levels need
- Two levels: gives . The smallest page is KB, with the 10, 10, 12 split above.
- Three levels: gives , so : 1 KB pages, 22 page-number bits split 8, 8, 6 (or 6, 8, 8 with the partly filled table outermost), each table at most entries of 4 bytes, exactly one page.
These are the smallest integers that satisfy the inequalities, so no smaller page size works for either case.
Important properties and observations
- Paging has no external fragmentation; it has internal fragmentation in the last page of each process.
- The offset field is the same width in logical and physical addresses; only the page number is translated.
- Page-table size depends on the logical address space; inverted-table size depends on physical memory.
- Multilevel tables save memory only because unused regions need no inner tables; each level adds one memory access on a TLB miss.
- The TLB must be flushed on a context switch unless its entries carry ASIDs.
Common misconceptions.
- "A TLB hit needs no memory access." The data access still happens; only the page-table read is saved.
- "More levels make paging faster." They make page tables smaller and misses slower.
- "An inverted table is indexed by page number." It is indexed by frame and searched (usually through a hash) by (pid, page).
GATE examination perspective
- Bit-field questions. Find offset bits from the page size, page-number bits from the logical address, frame bits from the physical memory; add the stated status bits to get the entry size.
- Page-table size. Entries times entry size; for multilevel tables, count the tables that must exist.
- Levels. Divide page-number bits by and round up; the outermost level takes the remainder.
- EAT conventions. Check whether TLB time is given or neglected, whether the data access is included, and how many levels the walk has.
- Inverted tables. Entries equal the number of frames; the entry holds pid and page number.
- Hex addresses. With 4 KB pages the offset is the last three hex digits.
Summary
Sources
- A. Silberschatz, P. B. Galvin, G. Gagne, Operating System Concepts, 10th ed., Wiley: Chapter 9 (9.3 Paging, 9.4 Structure of the Page Table).
- A. S. Tanenbaum, H. Bos, Modern Operating Systems, 4th ed., Pearson: Chapter 3 (3.3.1 Paging, 3.3.2 Page Tables, 3.3.3 Speeding Up Paging, 3.3.4 Page Tables for Large Memories, 3.5.3 Page Size, 3.5.5 Shared Pages).