Paging in Operating System (original) (raw)

Last Updated : 22 May, 2025

Paging is the process of moving parts of a program, called pages, from secondary storage (like a hard drive) into the main memory (RAM). The main idea behind paging is to break a program into smaller fixed-size blocks called pages.

To keep track of where each page is stored in memory, the operating system uses a page table. This table shows the connection between the logical page numbers (used by the program) and the physical page frames (actual locations in RAM). The memory management unit uses the page table to convert logical addresses into physical addresses, so the program can access the correct data in memory.

Paging in Memory Management

Paging is a memory management technique that addresses common challenges in allocating and managing memory efficiently. Here we can understand why paging is needed as a Memory Management technique:

**Terminologies Associated with Memory Control

Important Features of Paging

Working of Paging

When a process requests memory, the operating system allocates one or more page frames to the process and maps the process's logical pages to the physical page frames. When a program runs, its pages are loaded into any available frames in the physical memory.

Each program has a page table, which the operating system uses to keep track of where each page is stored in physical memory. When a program accesses data, the system uses this table to convert the program's address into a physical memory address.

**Steps Involved in Paging :

**Step 1 Divide Memory : Logical → Pages, Physical → Frames .

**Step 2 Allocate Pages : Load pages into available frames.

**Step 3 Page Table : Map logical pages to physical frames.

**Step 4 Translate Address : Convert logical to physical address.

**Step 5 Handle Page Fault : Load missing pages from disk.

**Step 6 Run Program : CPU uses page table during execution.

The mapping from virtual to physical address is done by the Memory Management Unit (MMU) which is a hardware device and this mapping is known as the paging technique.

Example

Number of frames = Physical Address Space / Frame Size = 4K / 1K = 4 = 22
Number of Pages = Logical Address Space / Page Size = 8K / 1K = 23

paging

The address generated by the CPU is divided into

  1. **Page number(p): Number of bits required to represent the pages in Logical Address Space or Page number
  2. **Page offset(d): Number of bits required to represent a particular word in a page or page size of Logical Address Space or word number of a page or page offset.

A **Physical Address is divided into two main parts:

  1. **Frame Number(f): Number of bits required to represent the frame of Physical Address Space or Frame number frame
  2. **Frame Offset(d): Number of bits required to represent a particular word in a frame or frame size of Physical Address Space or word number of a frame or frame offset.

So, a physical address in this scheme may be represented as follows:

**Physical Address = (Frame Number << Number of Bits in Frame Offset) + Frame Offset
where "<<" represents a bitwise left shift operation.

Hardware implementation of Paging

The hardware implementation of the page table can be done by using dedicated registers. But the usage of the register for the page table is satisfactory only if the page table is small. If the page table contains a large number of entries then we can use TLB(translation Look-aside buffer), a special, small, fast look-up hardware cache.

page_table

Hit and Miss In Paging

Main memory access time = m
If page table are kept in main memory,
Effective access time = m(for page table) + m(for particular page in page table)

Read more about - TLB hit and miss

Advantages of Paging

Disadvantages of Paging

Read more about - Memory Management Unit (MMU)

Also read - Multilevel Paging in Operating System
Also read - Paged Segmentation and Segmented Paging