Virtual Memory and Demand Paging
page 5 of 8
by Joydip Kanjilal
Feedback
Average Rating: 
Views (Total / Last 10 Days): 98746/ 58

How Demand Paging Works

When the CPU executes an instruction that is not available in the memory, a Page Fault occurs.  This means a page is being referenced, but the same is not present in the memory.  The Operating System is now responsible for bringing the appropriate page into memory from the disk.  The total turnaround time of a process is divided into CPU time and IO time.  Disk I/O takes a longer time than CPU and the process must wait until the page has been fetched from the disk. A module of the Operating System called the Page Fault Handler is given the control.  It gets the Page Table address and the page number of the faulting page along with the information needed to bring the required page into the main memory from the backing store.  The information also includes the disk address of the page in the backing store.  A longer IO is detrimental to the performance of the system as a whole because the CPU would remain idle for a considerable amount of time which is not feasible for a good Operating System design.  So, the CPU would schedule another process that could execute at the same point of time when the Disk IO is being performed so that the CPU idle time can be avoided.

The Operating System searches for the page in the File Map Table that contains the page number and the corresponding disk address of the page.  After acquiring the disk address, the OS schedules a disk read operation to get the page from the disk/physical storage.  The Memory Map Table is then searched to locate the first free frame for that page to be loaded.  After getting the free frame number, the OS updates the Page Map Table with the frame number and the reference bit.  Now the presence bit is set to indicate the presence of the page in memory.  The CPU is now instructed to restart the execution.  If the probability of the page fault is "p" and the memory access time is "ma," then the total time required is

(1 - p) x ma + p x page fault time.

Besides Demand Paging, there is another concept related to paging operation in the name of Anticipatory Paging.  This implies that the Operating System guesses the pages that can be referenced and fetches them from the backing store to put onto the main memory even before they need to be referenced.


View Entire Article

User Comments

Title: virtual memory and paging concepts   
Name: Suganthi Velusamy
Date: 2006-12-28 1:10:43 AM
Comment:
This is very very useful for me to know about the virtual memory concets and paging concepts clearly. Thanks a lot for you to make me to get a clear idea of what is virtul memory and all of its corresponding operations. Can u please guide me by an article for threading concepts in detailed manner?
Title: Mapping virtual address to physical   
Name: Swetha
Date: 2006-10-15 3:07:27 PM
Comment:
Hello Sir,

The article is very good for beginners like me.But ca you tell me whether can I write a code to map virtual address to physical addres.

Warm Regards
swetha
Title: Suggestion   
Name: Sandeep Acharya
Date: 2006-08-30 12:30:59 PM
Comment:
The article is really good. We all know that covering the paging concept in a small article is very tough. But I guess it could be better if you can throw some more light on the "Pure demand Paging" and how it could "Thrash" an application. I guess a pictorial/graphical explanation could be better. ANyway its a suggestion only. And I am really appriciating the article. Hoping to have some good articles like this in future.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-29 12:40:10 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search