Ticker

6/recent/ticker-posts

Header Ads Widget

Types of page replacement algorithm in Operating system

Types of page replacement algorithm

Mainly there are three types of page replacement algorithm let’s see that types of page replacement algorithm

·         1.FIFO (First In First Out)

·         2.Optimal page replacement

·         3.Least recently Used page

Let’s see all this one by one here I want you tell you that if you are not aware of what is paging or what is paging in operating system then kindly first go through that article it makes types of page replacement algorithm easy for you.

 

FIFO (First In First Out)

As we all know what is page and why we need to use this technique of page replacement so here this technique FIFO is used like name itself.

As we know when we need to transfer the process from virtual memory to RAM we transfer the process with the help of pages.

We store are process in the form of pages into virtual memory and we access that pages when we required that.

Here FIFO comes into the picture suppose you open chrome browser application so there are so many process running behind the scene so processor knows which process they need from virtual memory.

So processor sends that first process back which goes inside first into the virtual memory then second and then third and as many as required so this process calls FIFO which means first in first out.

 

Optimal Page Replacement

In optimal page Replacement algorithm, the pages are replaced which would not be used for the longest time in the future. So it calls optimal page replacement.

But we cannot implement it practically because in fact it is difficult to find out which page will be used in future.

Let us see this through an example:

types of page replacement algorithm

Here (+) = page fault

(*) = page hit

We have taken three frames in it. First of all 2,3,1 got empty slots, then page fault would happen three times.

Now we will replace 5 with 1 because in the future it will be late use, 3 is already there, then the page will be hit.

Will replace 4 with 3. Replace 7 with 4 because use of 4 will be late.

2 is already there, the page will be hit

5 is also already in memory, then the page will be hit back

We will replace 4 with 2 because 2 out of 2, 5, 7 came first. 

Hope so you understand

 

Least recently used page

In this, the page is replaced which has not been used in memory for a long time. It looks in the past side. This is also similar to optimal page replacement but it looks in the past side. So it is called least recently used page replacement algorithm.

It is easy to practically use this algorithm. This algorithm assumes that pages which have not been used for a long time will still be late use.

Let us see this through an example:

types of page replacement algorithm

Here (+) = page fault

(*) = page hit

Page fault = 9, page hit = 1

We have taken three frames in it.

First of all 2, 1 got empty slots, then 2 times the page will be faulted.

If 1 is already there then the page will be hit

If there is an empty slot in memory for 3 then no page will be replaced. And the page will be faulted.

5 no. If the page is not in memory, for this we will replace the page which has not been used for a long time. If 2 is not used here, we will replace it only.

Similarly, replace 2no.page with 1, 0 with 3, 3 with 5.

Replace 1 with 3, then replace 5 with 0.

So I hope you understand.

So after reading this full article on types of page replacement algorithm if you have any query then you can ask me in comment section and if you like the article do not forget to share this article to your friends and do email subscription for daily update direct to your mail box thank you for reading this article have a good day.

Related Posts :

1.Remote procedure call (RPC) in operating System

2.Types of Operating System

3.What is Paging in Operating System

Post a comment

0 Comments