There are many different page-replacement algorithms. Every operating system probably has its own replacement scheme. Let us watch various types of page replacement algorithms in this post. There are following types of page replacement algorithms :-
1. FIFO page replacement.
2. Optimal page replacement.
3. LRU page replacement.
In general, we want the algorithm which have the lowest page-fault rate. We evaluate an algorithm by running it on a particular string of memory references and computing the number of page faults. The string of memory references is called a reference string. We can generate reference strings artificially by using a random-number generator.
We use the reference string as follows for a memory with three frames :-
7 0 1 2 0 3 4 2 3 0 3 2 0 1 7 0 1
1. FIFO page replacement :-
It is the simplest page replacement algorithm. Its full form is First-In-First-Out. A FIFO page replacement associates with each page the time when page was brought into memory. When a page must be replaced, the oldest page is chosen. Notice that it is not necssary to record the time when a page is brought in. We can create a FIFO queue to hold all pages in memory. We replace the page at the head of the queue. When a page is brought into memory, we insert it at the tail of the queue.
For example. our three frams are initially empty.
The first three frames are initially empty. The first three references ( 7, 0, 1) cause page fault and are brought into these empty frames. The next reference (2) replace page 7, because 7 was brought at first. Since ) is the next reference and is present already in memory, we have no page fault there. And so on this algorithm works.
The FIFO page replacement algorithm is easy to understand and program. However, its performance is not always good.
Notice that, even if we select fot replacement a page that is in active use, everything still works correctly. After we replace an active pafe with a new one, a fault occurs almost immidiately to retrive the active page. Thus, a bad replacement choice increase the page fault rate and slows process execution.
2. Optimal page replacement :-
It is a type of page replacement algorithm. This algoritm has the lowest has the lowest page fault rate among all algorithms. This algorithm is also known as OPT or MIN. Its rule is simple as replace the page that will not be used for the longest period of time.
Use of this page replacement algorithm guaramtees the lowest possible page fault rate for a fixed number of frames.
Unfortunately, the optimal page replacement algorithm is difficult to implement, because it requres future knowledge of the refrence string. For example. our three frams are initially empty.
The first three frames are initially empty. The first three references ( 7, 0, 1) cause page fault and are brought into these empty frames. The reference to page 2 replaces page 7, because page 7 will not be used untill refrence 18, where as 0 will be used at 5, and page 1 at 14. The refrence to page 3 replaces page 1, as page 1 will be the last of the three pages in memory to be refrenced. again and so on..
3. LRU page replacement :-
It is a type of page replacement algorithm. Its full form is Least Recently Used. If the optimal algorithm is not feasible, perhaps an approximation of the optimal algorithm is possible. This algorithm is used. If we use recent past as an approximation of the near future, then we can replace the page that has not been used for the long period of time. This approach is the least recently used algorithm.
LRU replacement associates with each page the time of page's last use.When a page must be replaced, LRU chooses tha page that has not been used for the longest period of time. We can think of this strategy as the optimal page replacement algorithm looking backward in time, rather then forward.
For example. our three frams are initially empty.The first three frames are initially empty. The first three references ( 7, 0, 1) cause page fault and are brought into these empty frames. The reference to page 2 is replaced by page 7 because 7 ius used least recently among 7, 0 ,1. and so on..
Comments
Post a Comment
Please comment.