Skip to main content
Beginnerconceptual

What is paging in an operating system, and why is it used?

ReportedSource: GeeksforGeeks interview experience: Wipro Elite

Quick answer

Fixed-size pages map to frames through per-process page tables (cached by the TLB). Removes external fragmentation, enables virtual memory, isolation and sharing; costs internal fragmentation and translation overhead.

Paging divides a process's virtual address space into fixed-size pages and physical memory into frames of the same size (commonly 4 KB). Any page can be placed in any free frame.

Address translation. A virtual address = page number + offset. The page table maps the page number to a frame number; physical address = frame number + offset. The TLB caches recent translations so most lookups avoid reading the page table from memory.

Why it is used.

  • No external fragmentation: memory need not be contiguous.
  • Virtual memory: pages not in use can live on disk and be loaded on demand (page faults).
  • Isolation and protection: each process has its own page table and permission bits (read/write/execute).
  • Sharing: shared libraries and copy-on-write after fork.

Costs. Internal fragmentation (last page partly empty), page-table memory (solved with multi-level page tables), translation overhead (solved by the TLB).

Related terms. Page fault, page replacement (FIFO, LRU, optimal), thrashing, segmentation (variable-size segments).

Discussion