/    /  OS – Page Replacement Algorithms

Page Replacement Algorithms

 

What is page fault?

A page fault refers to a situation when a running program accesses a memory page that is mapped into the virtual address of the system but not loaded in the physical memory. 

Page faults are common as the physical memory is much smaller than the virtual memory. In this situation, the operating system needs to replace the existing page with a new page. For this, there are different page replacement algorithms.

 

Page Replacement Algorithms:

 

  1. First In First Out 

First In First Out or FIFO is one of the simplest page replacement algorithms. The OS keeps track of all the pages in the system, the oldest of them is at the front of the queue. 

When a page needs to be removed, the first in the queue is removed first.

 

 

  • Last In First Out

 

Last In First Out or LIFO is an algorithm where it replaces the newest page with the last page. 

 

 

  • Least Recently Used

 

The Least Recently Used or LRU Page Replacement Algorithm replaces the page least referred by the CPU for the longest time. 

 

 

  • Optimal Page Replacement Algorithm

 

Optimal Page Replacement Algorithm replaces the page that will not be used for the CPU for the longest time.

It cannot be practically implemented as the pages that will not be used in the future cannot be predicted accurately.

This algorithm is mostly used as a performance criterion for other algorithms.

 

 

  • Random Page Replacement Algorithm

 

Random Page Replacement Algorithm randomly replaces any page.

 

Reference

Page Replacement Algorithms