Demand paging is a form of virtual memory, where a page of memory will be paged in if a program tries to access it and the page is not already in the main memory. Therefore, demand paging only loads pages that should be brought into real memory during the execution process, it does not need to swap all the memory for a process from the secondary memory to the main memory during the program start up.

The advantage of this process is that, only pages that are needed during the execution process are loaded, so there is more space in the main memory and therefore more processes can be loaded, reducing context switching time, which normally uses up a large amount of memory resources. However, demand paging means that programs can face extra latency when they attempt to access a page for the first time, this process may also be vulnerable to possible security risks such as timing attacks.

Demand paging process;

1.Program attempts to find a page.

2.If the page is located in the main memory then the program runs as normal.

3.If the page cannot be located then what is known as a page-fault trap occurs.

4.Then the memory reference is checked to determine it is a valid reference to a location on secondary memory, if it is then the page will have to be paged in.

5.The desired page is scheduled to be read into main memory.

6.This operation is restarted at the point before the page-fault trap occurs. (Steps 1 & 2).

7.The program can now access the desired page in the main memory.

Post a Comment