What is paging in OS?

Paging in an operating system is a memory management technique that breaks up physical memory into fixed-sized blocks called frames and the logical memory of processes into blocks of the same size called pages. It allows the system to store parts of a process's memory in non-contiguous locations in RAM or secondary storage (virtual memory).

Real-World Example

Think of a bookshelf with books of uniform size. If you only have a few empty slots, you can take out the pages of a book, place them into these slots (frames), and retrieve them later to read the complete story. Similarly, in paging, a program is split into smaller, manageable parts that can fit into available memory slots.

How Paging Works

  1. Divide Memory into Frames: Physical memory is divided into equal-sized blocks called frames.
  2. Divide Processes into Pages: Logical memory (processes) is divided into equal-sized blocks called pages, matching the frame size.
  3. Page Table: The OS maintains a page table to map logical addresses (pages) to physical addresses (frames).
  4. Execution: When a process needs data, the CPU consults the page table to find its location in physical memory.

Why Paging is Used

  • Efficient Memory Utilization: Allows the OS to use available memory more effectively by filling gaps with smaller parts of processes.
  • Eliminates Fragmentation: Paging solves the problem of external fragmentation since any free frame can hold a page.
  • Supports Virtual Memory: Enables processes to use more memory than is physically available by swapping pages in and out of secondary storage.

Key Concepts in Paging

1. Logical Address

The address generated by the CPU, which is divided into:

  • Page Number: Index in the page table.
  • Page Offset: Specific location within the page.

2. Physical Address

The actual location in physical memory where a page resides.

3. Page Table

A data structure that maps each page number to a specific frame in physical memory.

4. Page Fault

Occurs when a requested page is not in memory. The OS retrieves it from secondary storage, which slows down the process.

Advantages of Paging

  • No External Fragmentation: Fixed-size pages eliminate gaps in memory.
  • Flexibility: Non-contiguous memory allocation allows efficient memory use.
  • Scalability: Supports processes larger than physical memory using virtual memory.

Disadvantages of Paging

  • Internal Fragmentation: Small unused space in frames can waste memory.
  • Overhead: Maintaining the page table adds computational and memory overhead.
  • Page Faults: Frequent page faults can degrade system performance (thrashing).

Importance of Paging

Paging is crucial for modern operating systems to efficiently manage memory, support multitasking, and enable large-scale applications. It also underpins virtual memory systems, making it foundational for system design and performance optimization.

For a deeper dive into memory management and paging, explore Grokking Multithreading and Concurrency for Coding Interviews or System Design Primer The Ultimate Guide.

TAGS
Coding Interview
System Design Interview
CONTRIBUTOR
Design Gurus Team
-

GET YOUR FREE

Coding Questions Catalog

Design Gurus Newsletter - Latest from our Blog
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Explore Answers
Why CE over CS?
What are the strategies for improving coding speed and accuracy?
What is the salary of a fresher in Cisco?
Which tips to follow for coding interviews in high-pressure situations?
What is a third stage interview?
What does Tesla stand for?
Related Courses
Grokking the Coding Interview: Patterns for Coding Questions course cover
Grokking the Coding Interview: Patterns for Coding Questions
The 24 essential patterns behind every coding interview question. Available in Java, Python, JavaScript, C++, C#, and Go. The most comprehensive coding interview course with 543 lessons. A smarter alternative to grinding LeetCode.
4.6
Discounted price for Your Region

$197

Grokking Modern AI Fundamentals course cover
Grokking Modern AI Fundamentals
Master the fundamentals of AI today to lead the tech revolution of tomorrow.
3.9
Discounted price for Your Region

$72

Grokking Data Structures & Algorithms for Coding Interviews course cover
Grokking Data Structures & Algorithms for Coding Interviews
Unlock Coding Interview Success: Dive Deep into Data Structures and Algorithms.
4
Discounted price for Your Region

$78

Design Gurus logo
One-Stop Portal For Tech Interviews.
Copyright © 2026 Design Gurus, LLC. All rights reserved.