In this tutorial, you will learn about virtual memory, its management within the operating system, and how it functions. Virtual memory is a technical concept that enables the execution of different processes that cannot fit entirely in memory. One significant advantage of this method is that programs can exceed the physical memory capacity.



Virtual memory abstracts primary memory into a broad, consistent array of storage, separating logical memory as viewed by the user from that of physical memory. This technique relieves programmers of the stress of memory storage limitations.

Uses of Virtual Memory

Virtual memory enables processes to share files and implement shared memory while providing a streamlined process creation mechanism. However, implementing virtual memory can be complex and requires careful execution to avoid significantly decreased performance.

What is Virtual Address Space (VAS)?

The virtual address space of a process refers to how the process is stored in memory in a logical (or virtual) view. Typically, the process begins at a specific logical address, such as address location 0, and then exists in contiguous memory. However, physical memory may be organized as page frames, meaning physical page frames may not be adjacent to each other. The memory management unit (MMU) maps logical pages to physical page frames in memory.

The Concept of Demand Paging

Consider how a program can be loaded from a disk into memory for execution. One option is to load the entire program into physical memory simultaneously, but this approach has a downside. The program may not need all the memory allocated to it right away, which can lead to unnecessary memory usage.

An alternative method is to load only the necessary pages when required. This technique is known as demand paging and is commonly used in virtual memory systems. With demand paging, pages are loaded only as they are needed during program execution, and pages that are not accessed are never loaded into physical memory.

A demand-paging system is similar to a paging system with a swapping feature. When a process needs to be executed, it is swapped into memory from secondary storage (usually a disk). Instead of swapping the entire process into memory, a "lazy swapper" is used. A "lazy swapper" only swaps a page into memory if it is required for execution, preventing unnecessary swapping of pages into memory.

Hardware Required for the Concept of Demand Paging

The hardware required for supporting demand paging is the same that is needed for paging and swapping:

  • Page table: The page table can mark an entry as invalid or unacceptable using a valid-invalid bit.
  • Secondary memory: Secondary memory retains those pages not in the main memory. The secondary memory is generally a high-speed disk. It is also known as a swap device, and the segment of disk used for this purpose is called swap space.


Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram