Professional Documents
Culture Documents
Example3:
70120 304230321201701
Example2: 1, 2, 3, 2, 1, 5, 2, 1, 6, 2, 5, 6, 3, 1, 3,6, 1,2,4,3
1 1 1 1 1 1 5 5 5 5 2 2 2 2 1 1 1 1 1 4 4
2 2 2 2 2 2 2 1 1 1 5 5 5 5 5 6 6 6 6 3
3 3 3 3 3 3 3 6 6 6 6 3 3 3 3 3 2 2 2
p p
p pf
f h
f
No of page faults=14
Hits=6
FIFO
•Advantages –
• It is simple and easy to understand & implement.
•Disadvantages –
• The process effectiveness is low.
• When we increase the number of frames while using FIFO, we are giving
more memory to processes. So, page fault should decrease, but here the
page faults are increasing. This problem is called as Belady’s Anomaly.
• Every frame needs to be taken account off.
FIFO
Advantages
•Simple and easy to implement.
•Low overhead.
Disadvantages
•Poor performance.
•Doesn’t consider the frequency of use or last used time, simply replaces the oldest
page.
•Suffers from Belady’s Anomaly(i.e. more page faults when we increase the number
of page frames).
Least Recently Used (LRU)
• Least Recently Used page replacement algorithm keeps track of page
usage over a short period of time. It works on the idea that the pages
that have been most heavily used in the past are most likely to be used
heavily in the future too.
• In LRU, whenever page replacement happens, the page which has not
been used for the longest amount of time is replaced.
Example 1:
Example 2:
0, 2, 1, 6, 4, 0, 1, 0, 3, 1, 2, 1
Example 3:
(7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2)
(7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2)
7 7 7 2 2 2 2 4 4 4 0 0 0
0 0 0 0 0 0 0 0 3 3 3 3
1 1 1 3 3 3 2 2 2 2 2
Page faults=9
Page hits =4
Least Recently Used (LRU)
Advantages
•Efficient.
•Doesn't suffer from Belady’s Anomaly.
Disadvantages
•Complex Implementation.
•Expensive.
•Requires hardware support.
Optimal Page algorithm
• An optimal page-replacement algorithm has the lowest page-fault rate of all
algorithms. An optimal page-replacement algorithm exists, and has been called
OPT or MIN.
• Replace the page that will not be used for the longest period of time. Use the time
when a page is to be used.
Example 1:
Example 2:
0, 2, 1, 6, 4, 0, 1, 0, 3, 1, 2, 1
Example 3:
(7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2,1,2,0,1,7,0,1)
1 1 1 1 1 1 1 1 6 6 6 6
2 2 4 5 5 5 5 5 5 2 2
3 3 3 3 3 3 3 3 3 3
0, 2, 1, 6, 4, 0, 1, 0, 3, 1, 2, 1
0 0 0 0 0 0 0 0 3 3 3 3
2 2 6 4 4 4 4 4 4 2 2
1 1 1 1 1 1 1 1 1 1