0% found this document useful (0 votes)
13 views3 pages

Virtual Memory and Demand Paging Explained

The document discusses virtual memory, a memory management technique that allows applications to run on systems with limited RAM by providing an abstraction of main memory. It highlights the benefits of virtual memory, such as increased multiprogramming and security, as well as limitations like potential system slowdowns and data loss risks. Additionally, it covers concepts like swapping and demand paging, explaining how they manage memory and affect performance through metrics like Effective Access Time (EAT).

Uploaded by

v3756155
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Virtual Memory and Demand Paging Explained

The document discusses virtual memory, a memory management technique that allows applications to run on systems with limited RAM by providing an abstraction of main memory. It highlights the benefits of virtual memory, such as increased multiprogramming and security, as well as limitations like potential system slowdowns and data loss risks. Additionally, it covers concepts like swapping and demand paging, explaining how they manage memory and affect performance through metrics like Effective Access Time (EAT).

Uploaded by

v3756155
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Operating System – By Prof. (Dr.

) Mohit Agarwal
Introduction to Virtual Memory:
Virtual memory is a memory management technique used by operating systems to give the
appearance of a large, continuous block of memory to applications, even if the physical
memory (RAM) is limited. It allows larger applications to run on systems with less RAM.
 The main objective of virtual memory is to support multiprogramming, the main
advantage that virtual memory provides is, a running process does not need to be
entirely in memory.
 Programs can be larger than the available physical memory. Virtual Memory provides
an abstraction of main memory, eliminating concerns about storage limitations.
 Virtual Memory Manager: is a software component which is responsible for managing
& maintenance of virtual memory.
 The basis of virtual memory is the noncontiguous memory allocation model.
 The virtual memory manager removes some components from memory to make room
for other components.
 The size of virtual storage is limited by the addressing scheme of the computer system.

Benefits of Using Virtual Memory


 Many processes maintained in the main memory.
 A process larger than the main memory can be executed because of demand paging.
 Higher degree of multiprogramming.
 It has twice the capacity for addresses as main memory.
 Faster Execution for local program: When only a portion of a program is required for
execution, speed has increased.
 Security: Memory isolation has increased security.
 Memory allocation is comparatively cheap.

Operating System – Prof. (Dr.) Mohit Agarwal (Dept. of CSE- PSIT Kanpur)
 It doesn't require outside fragmentation.
 Automatic data movement is possible.
Limitation of Virtual Memory
 It can slow down the system performance, as data needs to be constantly transferred
between the physical memory and the hard disk.
 It can increase the risk of data loss or corruption, as data can be lost if the hard disk
fails or if there is a power outage while data is being transferred to or from the hard
disk.
 It can increase the complexity of the memory management system, as the operating
system needs to manage both physical and virtual memory.

Swapping:
Swapping in an operating system is a process that moves data or programs between the
computer's main memory (RAM) and a secondary storage (usually a hard disk or SSD). This
helps manage the limited space in RAM and allows the system to run more programs than it
could otherwise handle simultaneously.
Swapping has been subdivided into two concepts: swap-in and swap-out.
1. Swap-out is a technique for moving a process from RAM to the hard disc.
2. Swap-in is a method of transferring a program from a hard disc to main memory, or
RAM.

Operating System – Prof. (Dr.) Mohit Agarwal (Dept. of CSE- PSIT Kanpur)
Demand Paging in Operating System
Demand paging is a technique used in virtual memory systems where pages enter main memory
only when requested or needed by the CPU. In demand paging, the operating system loads only
the necessary pages of a program into memory at runtime, instead of loading the entire program
into memory at the start. A page fault occurred when the program needed to access a page that
is not currently in memory.
The operating system then loads the required pages from the disk into memory and updates the
page tables accordingly. This process is transparent to the running program and it continues to
run as if the page had always been in memory.

Performance of Demand Paging:


The performance of demand paging depends primarily on the page fault rate and the cost of
servicing a page fault.
Effective Access Time (EAT)
The performance of demand paging is measured using Effective Access Time (EAT):
EAT = (1−p)×Memory Access Time + p×Page Fault Time
Where:
 p = Page fault rate (0 ≤ p ≤ 1)
 Memory Access Time = Time to access a page in RAM (e.g., 100 ns)
 Page Fault Time = Time to handle a page fault (e.g., 10 ms)
Example Calculation:
Assume: Memory access time = 100 ns
Page fault service time = 10 ms = 10,000,000 ns
Page fault rate = 0.001 (0.1%)
EAT=(1−0.001)×100+0.001×10,000,000=100.1+10,000=10,100.1 ns
EAT=(1−0.001)×100+0.001×10,000,000=100.1+10,000=10,100.1ns
👉 Even a tiny page fault rate significantly increases access time.

Operating System – Prof. (Dr.) Mohit Agarwal (Dept. of CSE- PSIT Kanpur)

Common questions

Powered by AI

Swapping in operating systems refers to the process of moving data or programs between the computer's main memory (RAM) and secondary storage (such as a hard disk). Swap-out involves moving a process from RAM to a hard disk, freeing up space in RAM, while swap-in refers to bringing a process from the hard disk back into RAM, allowing a process to run. This mechanism allows the system to manage limited RAM by running more programs than would otherwise fit entirely in memory .

Effective Access Time (EAT) is crucial for analyzing demand paging performance as it combines both memory access time and the page fault service time, highlighting the trade-off between memory use efficiency and speed. It is calculated using the formula: EAT = (1 − p) × Memory Access Time + p × Page Fault Time, where p is the page fault rate. This quantifies how frequently page faults occur and their impact on overall access time. Even minimal page fault rates can dramatically increase effective access time, thus influencing system performance significantly .

Virtual memory can slow down system performance because data must be constantly transferred between physical memory and the hard disk, which is generally slower than RAM. Furthermore, there is an increased risk of data loss or corruption in case of hard disk failures or power outages during data transfer. Additionally, virtual memory adds to the complexity of the memory management system as both physical and virtual memory need to be managed by the operating system .

A page fault in a demand paging system occurs when the CPU attempts to access a page not currently loaded in RAM. The operating system detects the missing page and pauses program execution. It then loads the required page from the hard disk into RAM, updates the page tables to reflect the change, and resumes the program as though the page had been present. This process is seamless and transparent to the application, allowing it to continue execution without manual interruption or data handling errors by the user .

Demand paging is a technique in virtual memory systems where pages are loaded into main memory only as they are required by the CPU. The system does not load an entire program into memory initially, but instead waits until the CPU requires a page. This results in a page fault if a needed page is not in memory, prompting the operating system to load the page from disk. The performance impact of demand paging is mainly determined by the page fault rate and the cost of servicing a page fault. Even a low page fault rate can significantly increase the effective access time, reducing the system's performance .

Virtual memory provides the abstraction of a large, continuous block of memory, allowing applications to run without concern for the actual physical memory limits. It enables processes that may be larger than the physical memory to be executed by swapping the necessary parts in and out of the memory as needed (demand paging). This abstraction ensures that storage limitations do not constrain the size of the applications that can be effectively run on a system .

Virtual memory supports a higher degree of multiprogramming by allowing more processes to reside in memory simultaneously. Since it permits only parts of programs to be loaded in RAM at a time, physical memory is utilized more efficiently. This increases the number of processes that can run concurrently without the need for additional physical memory, thus enhancing overall system throughput and balancing CPU and I/O operation demands .

Virtual memory improves overall system efficiency by automating data movement between RAM and disk storage. This automation optimizes memory usage by ensuring that only the required pages are in memory while less frequently used data remains on disk. It reduces programmer burden, allowing developers to write applications without needing detailed memory management knowledge. Additionally, it optimizes the time-cost trade-off by minimizing unnecessary data transfers and better utilizing available memory resources, ensuring smooth and efficient system operations .

The main objective of virtual memory is to support multiprogramming by giving applications the appearance of a large, continuous block of memory. This abstraction allows larger applications to run on systems with less RAM, and it also means that a running process does not need to be entirely in memory .

Virtual memory enhances security through memory isolation, which ensures that processes are separated from each other in memory space. This prevents a process from accessing the memory space of another process, thereby protecting data and ensuring that processes do not interfere with each other’s execution .

You might also like