Skip to content
The Computer Science
TheCScience
  • Engineering Subjects
    • Human Values
    • Computer System Architecture
    • Microprocessor
    • Digital Communication
    • Internet of Things
  • NCERT Solutions
    • Class 12
    • Class 11
  • Solutions
    • HackerRank
      • C Solutions
      • C++ Solutions
      • Java Solutions
      • Python Solutions
      • Algorithms Solutions
      • Data Structures Solutions
    • HackerEarth Solutions
    • Leetcode Solutions
  • JEE 2027
The Computer Science
TheCScience

Demand Paging in Operating Systems | OS Tutorials

YASH PAL, June 25, 2026June 25, 2026

In an operating system, demand paging is similar to a paging system with swapping. In demand paging, a page is loaded/swapped into memory when needed, i.e., when a logical address generated by a process points to a page that is not present in memory. This is done by a lazy swapper.

Table of Contents

  • Demand Paging
    • Hardware
    • Handling Page Fault
    • Performance of Demand Paging (By calculating Effective Access Time)

Demand Paging

To facilitate demand paging, the entire logical address space of a process is maintained on a secondary storage device like a fast disk. We call this disk the paging device. Figure 1 illustrates the demand paging scheme.

Transfer page to paging device in demand paging in operating system
Figure 1: Transfer Page to Paging Device
  • While initiating execution of a process, an area is allocated on the paging device for this logical address space, and its code and data are copied into this space. This space is called the swap space of the process.
  • A page is loaded from this area into the memory when needed. When the virtual memory handler decides to remove a page from memory, the page is copied back into the swap space if it was modified since the last time it was loaded into memory.
  • Hence, this way, the swap space contains an up-to-date copy of every page that is not present in memory.
  • Demand paging involves interaction between hardware and software components of the virtual memory, i.e., between the MMU and the virtual memory handler.
  • Three concepts are involved in understanding the operation of demand paging. These are:
    1. Page faults (also called missing page interrupts).
    2. Page-in and page-out operations.
    3. Page replacement.

Hardware

  • With this scheme, we need some form of hardware support to distinguish between those pages that are in memory and those that are on the disk.
  • The valid-invalid bit scheme can be used for this purpose; when this bit is set to valid, this value indicates that the associated page is both legal and in memory.
  • If the bit is set to invalid, this value indicates that the page is not valid, or is valid but is currently on the disk.
  • Figure 2 depicts the concept.
Depicts the concept of demand paging
Figure 2: Depicts the concept

Figure 3 illustrates the concept of demand paging.

Example of demand paging
Figure 2: Example of Demand Paging

Page fault trap: While performing address translation for a logical address, the MMU checks the valid bit of the page table entry. If the process is not present in memory, the MMU raises an interrupt called Page fault trap or Missing Page Interrupt.

Handling Page Fault

The procedure of handling a page fault is carried out in six steps as given below: (also shown in Figure 3).

Steps involved in page fault handling in operating system
Figure 3: Steps involved in page fault handling
  • Step 1: Firstly, check the internal table for this process to determine whether the reference was a valid or invalid memory access.
  • Step 2: If the reference was invalid, we terminate the process. If it were valid, but we have not yet brought in that page. We now page in the latter.
  • Step 3: We find a free frame.
  • Step 4: Then, we schedule a disk operation to read the desired page into the newly allocated frame.
  • Step 5: When the disk read is complete, we modify the internal table kept with the process and the page table to indicate that the page is now in memory.
  • Step 6: Restart the instruction that was interrupted by the illegal address trap.

Performance of Demand Paging (By calculating Effective Access Time)

Demand paging can have a significant effect on the performance of a computer system. To compute the effective access time for a demand-paged memory system. Let ma be the memory access time, generally from 10 to 200 nanoseconds.

If page fault = 0, then
effective access time = Memory access time

If a page fault occurs, then read the relevant page from the disk and access the desired word. Let P be the probability of a page fault (0 <= P <= 1). Make P close to 0 (which means the page fault rate is low). Then

Effective access time = (1 - P) x ma + P x Page fault time

To compute the effective access time, we must know how much time is needed to service a page fault.

engineering subjects Operating System Operating System

Post navigation

Previous post

Leave a Reply

Your email address will not be published. Required fields are marked *

Engineering Core Subjects

Digital Communication Subject
Internet of Things Subject
Computer Architecture subject
Human Value Subject

JEE Study Materials

JEE Physics Notes
JEE Chemistry Notes

TheCScience

At TheCScience.com, our mission is to make quality education accessible to everyone. We provide in-depth, easy-to-understand articles covering Secondary, Senior Secondary, and Graduation-level subjects.

Pages

About US

Contact US

Privacy Policy

DMCA

Our Tools

Hosting - get 20% off

Engineering Subjects

Internet of Things

Human Values

Digital Communication

Computer System Architecture

Microprocessor

Programming Tutorials

Data Structure and Algorithm

C

Java

NCERT

Class 12th

©2026 TheCScience | WordPress Theme by SuperbThemes