Optimal Page Replacement
Goal:- Program for Optimal page replacement Method.
Method:- Replace the page that will not be used for the longest period of time.
Explanation:- As we seen in FIFO page Replacement Algorithm the problem is Belady's Anomaly and this lead us to discovery of an algorithm that will have minimum page fault rate.The search ends at Optimal Page Replacement.
Optimal Page replacement algorithm will never suffer from Belady's Anomaly.
Use of this algorithm guarantees the lowest page fault rate for fixed no. of frames.
For evaluating an algorithm we take a particular string of memory references ,called reference string.
In Optimal page replacement algorithm- for each page we track the time when it was brought into the memory and when any replacement request comes then we look for the page which is not going to be used in next future.
Page Fault:- Page Fault is a interrput that occurs when a program request page that is not in real memory.Then this interrput sends signal to OS to fetch that page from Virtual memory and load it into RAM.
**Program explained here counts the no. of page fault occurs when a input reference string is implemented onto Memory according to optimal replacement method.
Example:-
Reference string- 7,0,1,2,0,3,0,4
No. of frames: 3
Frame NO.
|
Reference String(Page Values)
|
Initially
|
7
|
0
|
1
|
2
|
0
|
3
|
0
|
4
|
1
|
-1
|
7
|
7
|
7
|
2
|
2
|
3
|
3
|
4
|
2
|
-1
|
-1
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
3
|
-1
|
-1
|
-1
|
1
|
1
|
1
|
1
|
1
|
1
|
When any page value already presented in frames then no page fault will occur.
Program:-
Output:-
|
Optimal Page Replacement |
If you want to share more information about topic discussed above or find anything incorrect Please do comments.
For more Programs Stay Connected..Like us on Facebook.
0 comments:
Post a Comment