2. HOME PREVIOUS TOPIC NEXT
PREVIOUS QUESTION PAPERS FOR OS
CPP TUTORIALS
3. Recap
In the last class, you have learnt
• Concepts of page replacement
• Page replacement algorithm
• FIFO
3
4. Objective
On completion of this class, you would be able
to know
• LRU algorithm
• Optimal algorithm
4
5. Least Recently Used (LRU) Algorithm
• LRU algorithm chooses that page that has not
been used for the longest period of time
• LRU algorithm looks at the pages which are
already page faulted
5
6. LRU Page Replacement
The LRU algorithm produces 12 page faults for
the reference string
7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1
6
7. Least Recently Used (LRU) Algorithm
Advantages
LRU policy is often used as a page replacement
algorithm
It is quite good algorithm
It is easy to choose that has already page faulted
and not in use for long period
7
8. Least Recently Used (LRU) Algorithm
Disadvantages
Problem is how to implement LRU replacement
Require substantial hardware assistance
Problem in determining the frame order by the
time of last use
8
9.
10. Optimal Algorithm
Replace page that will not be used for longest
period of time
4 frames example
Reference string : 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
1 4
2 6 page faults
3
4 5
How do you know this?
Used for measuring how well your algorithm
performs 10
16. Summary
In this class, you have learnt
• LRU page replacement algorithm
- advantages and disadvantages
• Optimal page replacement algorithm
- advantages and disadvantages
16
17. Frequently Asked Questions
1. What is meant by Page replacement?
2.Explain the LRU algorithms
3. What are the advantages and disadvantages of LRU?
4. Explain the concept of optimal Page replacement
algorithm
5. Write the advantages and disadvantages of Optimal page
replacement algorithm
17
18. Quiz
1. LRU algorithm chooses that page that has not been
used for the ________period of time
a) Shortest
b) Longest
c) Widest
d) None
18
19. Quiz
2. __________has the lowest page fault rate
a) FIFO
b) LRU
c) Optimal
d) None
3. ___________ requires future reference string
a) FIFO
b) LRU
c) Optimal
d) None
19
20. Quiz
4. __________never suffers from Belady’s anomaly
a) Optimal replacement
b) LRU
c) FIFO
d) None
5. Algorithm Replace page that will not be used for longest
period of time
a) LRU
b) Optimal replacement
c) FIFO
d) None
20