Given reference to the following pages by a program 0, 9, 0, 1, 8, 1, 8, 7, 8,…
2017
Given reference to the following pages by a program 0, 9, 0, 1, 8, 1, 8, 7, 8, 7, 1, 2, 8, 2, 7, 8, 2, 3, 8, 3 How many page faults will occur if the program has three page frames available to it and uses an optimal replacement?
- A.
7
- B.
8
- C.
9
- D.
None of these
Attempted by 75 students.
Show answer & explanation
Correct answer: A
To solve this, simulate the Optimal Page Replacement algorithm with 3 frames using the reference string: 0, 9, 0, 1, 8, 1, 8, 7, 8, 7, 1, 2, 8, 2, 7, 8, 2, 3, 8, 3.
Page faults occur when a page is not in memory. When all frames are full, replace the page that will not be used for the longest time in the future.
Step | Page | Frames | Fault? | Reason for Replacement |
1 | 0 | [0, -, -] | Yes | Initial load |
2 | 9 | [0, 9, -] | Yes | Initial load |
3 | 0 | [0, 9, -] | No | Hit |
4 | 1 | [0, 9, 1] | Yes | Initial load |
5 | 8 | [8, 9, 1] | Yes | 0 is never used again. |
6 | 1 | [8, 9, 1] | No | Hit |
7 | 8 | [8, 9, 1] | No | Hit |
8 | 7 | [8, 7, 1] | Yes | 9 is never used again. |
9 | 8 | [8, 7, 1] | No | Hit |
10 | 7 | [8, 7, 1] | No | Hit |
11 | 1 | [8, 7, 1] | No | Hit |
12 | 2 | [8, 7, 2] | Yes | 1 is never used again. |
13 | 8 | [8, 7, 2] | No | Hit |
14 | 2 | [8, 7, 2] | No | Hit |
15 | 7 | [8, 7, 2] | No | Hit |
16 | 8 | [8, 7, 2] | No | Hit |
17 | 2 | [8, 7, 2] | No | Hit |
18 | 3 | [8, 3, 2] | Yes | 7 is never used again. |
19 | 8 | [8, 3, 2] | No | Hit |
20 | 3 | [8, 3, 2] | No | Hit |
Summary
Total Page Faults: 7
Total Page Hits: 13
There will be 7 page faults.
A video solution is available for this question — log in and enroll to watch it.