OPR



Optimal Page Replacement Algorithm:

In this algorithm, OS replaces the page that will not be used for the longest period of time in future.

The idea is simple, for every reference we do following :

1.If referred page is already present, increment hit count.

2.If not present, find if a page that is never referenced in future. If such a page exists, replace this page with new page. If no such page exists, find a page that is referenced farthest in future. Replace this page with new page.

Advantages:

  • Complexity is less and easy to implement.

  • Assistance needed is low i.e Data Structure used are easy and light.

Disadvantages:

  • OPR is perfect, but not possible in practice as the operating system cannot know future requests.

  • Error handling is tough.
image of fifo algo

Simulation

Click on the button below to try out the execution of OPR algorithm



Simulate