In: Computer Science
Consider the following reference string:
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1
Find the number of Page Faults with FIFO, Optimal Page Replacement, and LRU with four free frames that are initially empty. Which algorithm gives the minimum number of page faults?
Solution
FIFO
7 |
3 |
3 |
3 |
3 |
2 |
2 |
0 |
0 |
4 |
4 |
4 |
4 |
7 |
1 |
1 |
1 |
0 |
0 |
0 |
0 |
2 |
2 |
2 |
2 |
1 |
1 |
1 |
4 1 1 1 1 1 1
Number of page fault is
=4+1+1+1+1+1+1
=4+6
=10
---
Optimal
7 |
3 |
3 |
1 |
1 |
0 |
0 |
0 |
0 |
0 |
1 |
1 |
4 |
4 |
7 |
2 |
2 |
2 |
2 |
2 |
4 1 1 1 1
Number of page fault is
=4+1+1+1+1
=4+4
=8
---
LRU
7 |
3 |
3 |
3 |
7 |
0 |
0 |
0 |
0 |
0 |
1 |
1 |
4 |
1 |
1 |
2 |
2 |
2 |
2 |
2 |
4 1 1 1 1
Number of page fault is
=4+1+1+1+1
=4+4
=8
Total Number of Page replacements
FIFO-10
Optimal-8
LRU-8
Therefore Both Optimal and LRU gives the minimum number of page faults
---
all the best