Day 112 - Page Replacement In Virtual Memroy

So far in Virtual Memory we have learned what virtual memory is and one of the techniques that are used to implement VM. Now we will be looking at Page Replacement which is what is says. It a way to replace pages in the memory in multiprogramming systems.

In multiprogramming systems, almost all of the programs use half of the memroy of their size. For example the program with 10 pages only actually uses 5 pages. The demand paging mechanism saves the I/O time necessary to load the five pages that are never used. In this case the degree of multiprogramming should be increased.

Increase in the degree of the multiprogramming may leads to problems like over allocation of memory.

If a page fault occurs, the OS checks the internal page table. It determines where the page is in the disk but does not find any free frame in the memory to swap it into. For this situation, the OS has following ways for it to be solved.

  • Either it terminates the use program immediately; or
  • It swaps out pne program and free all of its frames from the memory. It in turn reduces the degree of multiprogramming.

That where Page Replacement comes in as another possibility to this situtaion.

What Is Page Replacement?

Page Replacement is another possibility to the situation where a page fault occurs requesting for page in the memory but there is frame free in the memory for the page to be loaded. Page Replacement frees one frame from the memroy that is not being used right now by any program. It writes the contents of the frame in the disk and update the page table to indicate that this page is not being used right now and is not in the memory. The freed frame now can be used to load the requested page. The page fault processing procedure can be modified to include the page replacement mechanism:

  • First find the required page's location on the disk.
  • Find the free frame and if there is, use it or else use a page replacement algorithm to select a frame from the memory, write it to disk, change the frame and frame table accordingly.
  • Read the requested page into the free frame in the memory and chage the frame table.
  • Restart the user process.

If there is no frame free in the memory at the time of page fault, page replacement occurs. This doubles the page fault processing but increses the effective access time.

There are many Page Replacement algorithms that are used to solve this problem. In next post we will be looking into some of those.


zainscizainsci