Winter Semester 2026–27 · VIT-AP · BACSE106 · Operating Systems · Dr. Krithika L.B

Session 4.3: Paging and the Translation Look-aside Buffer

Non-contiguous allocation with fixed-size pages and frames: splitting addresses into page number and offset, the page table, the TLB cache and effective access time, protection, sharing and page-table structures.

Module 4 1.5 hours Theory CO4
← Before
4.2 Contiguous allocation
Fits and fragmentation
You are here
4.3 Paging and the Translation Look-aside Buffer
Module 4 · Memory and File Management
Next →
4.4 Segmentation
The programmer's view

Learning objectives

By the end of this session you should be able to:

  • Explain pages, frames and the page table and why paging removes external fragmentation.
  • Translate logical to physical addresses given page size and page table.
  • Describe the TLB lookup on hit and miss and compute effective access time.
  • Explain valid–invalid bits, protection bits and shared pages.
  • Compare hierarchical, hashed and inverted page tables.

Lecture notes

1. The idea of paging

Divide physical memory into fixed-size blocks called frames and logical memory into blocks of the same size called pages. A process's pages can be loaded into any free frames. A page table per process records which frame holds each page. No external fragmentation — any free frame will do.

Logical memory

page 0
page 1
page 2
page 3

Page table

0 → 1
1 → 4
2 → 3
3 → 7

Physical memory

frame 0
frame 1: page 0
frame 2
frame 3: page 2
frame 4: page 1
frame 5–6
frame 7: page 3

2. Address translation

Every logical address is split into a page number p (index into the page table) and a page offset d. Page sizes are powers of two (4 KB is typical), so the split is just bits: for a logical address space of 2m and page size 2n, the high m − n bits are p and the low n bits are d.

\[ p = \left\lfloor \frac{\text{logical}}{\text{page size}} \right\rfloor, \quad d = \text{logical} \bmod \text{page size}, \quad \text{physical} = f \times \text{page size} + d \]

Worked example

Page size 1 KB (1024 bytes), page table [5, 2, 7, 0], logical address 2100.

p = ⌊2100 / 1024⌋ = 2, d = 2100 − 2048 = 52. Frame f = table[2] = 7. Physical = 7 × 1024 + 52 = 7220.

Bits: with 1 KB pages, d is the low 10 bits; a 16-bit logical address has a 6-bit page number → 64 pages.

Simulator — paging address translationTry other addresses, or an address beyond the table to see the trap.

Paging has no external fragmentation but has internal fragmentation in the last page: a process of 72 766 bytes with 2048-byte pages needs 36 pages (35 full + 1086 bytes), wasting 962 bytes. On average half a page per process is wasted — an argument for small pages; page-table size argues for large pages.

3. Hardware support: the page table and the TLB

Page tables are large, so they live in main memory, pointed to by the page-table base register (PTBR). A context switch just changes the PTBR. But now every data access needs two memory accesses — one for the page-table entry, one for the data — halving speed.

The fix is a small, fast associative cache of recent translations: the Translation Look-aside Buffer (TLB), with typically 32–1024 entries searched in parallel.

The CPU produces logical address (p, d).

The TLB is searched for p — all entries compared in parallel.

Hit: frame f is available immediately → access memory at (f, d). One memory access in total.

Miss: read the page-table entry from memory (extra access), get f, and insert (p, f) into the TLB (replacing an entry, e.g. LRU), then access (f, d).

Entries belong to one process: the TLB is flushed on a switch, or each entry carries an ASID (address-space identifier) so entries of several processes can coexist.

Effective memory-access time (EAT)

With hit ratio α and memory access time m (TLB search time ignored):

\[ \text{EAT} = \alpha \cdot m + (1-\alpha) \cdot 2m \]

m = 100 ns: α = 80% → 0.8 × 100 + 0.2 × 200 = 120 ns (20% slowdown). α = 99% → 0.99 × 100 + 0.01 × 200 = 101 ns (1% slowdown). If a TLB search takes ε ns, add ε to both terms.

4. Protection and sharing

  • Each page-table entry has protection bits (read/write/execute) and a valid–invalid bit: invalid means the page is not part of the process's logical address space → trap.
  • Shared pages: reentrant (read-only) code such as an editor or libc can be mapped into the page tables of many processes, pointing to the same frames — 40 users of a 150 KB editor need one copy, not 40.

5. Structure of the page table

Hierarchical (multi-level)

A 32-bit address space with 4 KB pages needs 220 entries (4 MB per process). Page the page table: an outer table points to pages of the inner table (two-level: p1 | p2 | d). 64-bit x86 uses four levels.

Hashed page table

Hash the virtual page number into a table of chains; used for address spaces larger than 32 bits.

Inverted page table

One entry per physical frame (pid, page) instead of one table per process — saves memory, but lookup requires a search (use hashing).

VideoBytes

Paging and address translation

Video coming soon

Paging and address translation

Recorded by Dr. Krithika L.B. Slot m4-paging

The TLB and effective access time

Video coming soon

The TLB and effective access time

Recorded by Dr. Krithika L.B. Slot m4-tlb

Interactive lessons

Work through these in order after the lecture — each one expands a part of the notes with diagrams, hover notes and a quick check.

Lab connection

Check your understanding

Answer each question in your own words first, then reveal the model answer.

Revealed 0
Page size 4 KB, page table [3, 8, 1, 6]. Translate logical address 9000.

p = ⌊9000/4096⌋ = 2, d = 9000 − 8192 = 808, f = 1 → physical = 4096 + 808 = 4904.

A 32-bit logical address uses 4 KB pages. How many bits for p and d?

d = 12 bits (212 = 4096), p = 20 bits → 220 pages.

Memory access 50 ns, TLB hit ratio 90%, TLB search negligible. EAT?

0.9 × 50 + 0.1 × 100 = 55 ns.

Does paging suffer from fragmentation?

No external fragmentation, but internal fragmentation in the last page of each process.

Why do inverted page tables save memory?

There is one entry per physical frame for the whole system, instead of a large table for every process.

Key takeaways

  • Pages (logical) map to frames (physical) through a per-process page table; no external fragmentation.
  • physical = frame × page size + offset; p and d are just the high and low bits.
  • The TLB caches translations: EAT = α·m + (1 − α)·2m.
  • Valid/protection bits protect; shared frames share code; big tables become hierarchical, hashed or inverted.

Where this leads

Paging chops a program into equal pieces that mean nothing to the programmer. Segmentation divides memory along the program's own logical units.

Continue to 4.4 — Segmentation →