Page Replacement Algorithms in OS | Page Replacement Policy in OS

What is Page Replacement in Operating System

Page Replacement Definition – Page replacement policies decides that which type of page should be replaced, but these page replacement strategies are implemented when requested page is not existed into primary memory. Here, we will explain all page replacement algorithms.

Read More – Virtual Memory in Operating System

Why to Need of Page Replacement Algorithms

Page Replacement Algorithms play vital role in the virtual memory management, because on the base of those Pages replacement policies can be specified that which memory block (page) should be swap out, arising memory space for needed page. Main objective of all Page replacement policies are to decrease the maximum number of page faults.

Page Fault – Page fault means memory error, and page fault occurs when currently programs try to access memory page for mapping into virtual address space, but it is not able to load into physical memory then it is known as “Page Fault”.

Types of Page Replacement Algorithms

There are various page replacement techniques, and we will explain each one

  • FIFO Page Replacement Algorithm
  • LIFO Page Replacement Algorithm
  • LRU Page Replacement Algorithm
  • Optimal Page Replacement Algorithm
  • Random Page Replacement Algorithm

FIFO Page Replacement Algorithm

This page replacement algorithm is very easy and simple because this algorithm is based on the “First in First out“principle. In which operating system uses the line as queue that store all information of all pages in the computer memory.

As per FIFO principle, oldest page is replaced at the front side and most recent page is replaced at the rear side.

Advantages of FIFO Page Replacement

  • It uses simple method, and easy to use.
  • It does not give more overhead.

Disadvantages of FIFO Page Replacement

  • Worst performance
  • Don’t use the frequency of last used time, just replace the oldest page.
  • Getting increase the page faults, while increasing page frames.

LIFO Page Replacement Algorithm

LIFO stands for “Last in First out“, and it performs all activities like LIFO principle. In this algorithm, newest page is replaced which is arrived at last in to primary memory, and it uses the stack for monitoring all pages.

LRU Page Replacement Algorithm

LRU stands for “Least Recently Used”, and it helps to operating system for searching such page that is used over the short duration of time frame. This page replacement algorithm uses the counter along with even page, and that counter is known as aging registers.

LRU algorithm helps to select that page which is not needed for long life in to primary memory.

Advantages of LRU Page Replacement

  • Most efficient
  • It helps to open for full analysis.
  • Easy to identify the faulty page that is not needed to long time.
  • Not getting more suffers from Belady’s Anomaly.

Disadvantages of LRU Page Replacement

  • It has more complexity.
  • It has to need additional Data Structure.
  • More expensive
  • Need to highly hardware support.

Optimal Page Replacement Algorithm

Optimal Page Replacement Algorithm is very excellent page replacement policy because it helps to provide least number of page faults, so it is called of “OPT”, “Clairvoyant Replacement Algorithm”, and “Belady’s optimal page policy”.

Features are

  • In this algorithm, such pages are replaced which are not needed to long life duration in future.
  • It has very low page fault rate compare to other algorithm.

Advantages of Optimal Page Replacement

  • Easy to use
  • Easy to implement data structures for best result
  • Excellent efficiency
  • Less need to assistance

Disadvantages of Optimal Page Replacement

  • More time consumption
  • Need future awareness of program.
  • Difficult to error handling
  • Not easy to implement, because O/S not able to trace future request.

Random Page Replacement Algorithm

In this algorithm, randomly page can be replaced anytime, but it works like other page replacement policy such as FIFO, LIFO, LRU and Optimal.

Page Faults in LRU with Example

Leave a Reply

Your email address will not be published. Required fields are marked *