• When the process try to access location that are not in memory the hardware trap to the operating system is generated. ( to read more, refer our articles memory protection and interrupt mechanism in detail. )
  • The operating system reads the desire page into memory and restarts the process. It never brings a page into memory until it is required.
  • If there is sufficient memory to allocate the desired page then any of the frame is allocated to this page.
  • If there is no sufficient memory to allocate this desired page at that time it will free some frame (by swapping. you can read more on swapping here. ) for that page and that is called a page replacement. There are many algorithms to replace a desire page like FIFO, LRU, optimal etc.
  • In memory there are number of processes executing simultaneously.
  • We increase the multi-programming level so that average memory usage is also available to the physical memory. There are number of cases to implement a basic page replacement scheme.

Page Replacement

Basic Scheme of Page Replacement

  1. Find the location of the desire page on the disk. Find a free frame
  2. If there is a free frame, use it.
  3. If there is no free frame use page replacement algorithm to select a page from memory. That page frame is called victim frame. Writing the victim from memory to a disk changes a page table values.
  4. Read the desire page into the newly free frame and reset its entry to a page table.
  5. Reset that process with new values.