Correct option is A
We are given the reference string:
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1
Number of frames: 3
We need to calculate the hit ratio using the Optimal Page Replacement Algorithm.
The Optimal Page Replacement algorithm replaces the page whose next occurrence is farthest in the future (or which will not be used again).
Let's trace the reference string.
Step | Page | Frames after reference | Hit/Fault |
1 | 7 | 7 | Fault |
2 | 0 | 7, 0 | Fault |
3 | 1 | 7, 0, 1 | Fault |
4 | 2 | 2, 0, 1 | Fault |
5 | 0 | 2, 0, 1 | Hit |
6 | 3 | 2, 0, 3 | Fault |
7 | 0 | 2, 0, 3 | Hit |
8 | 4 | 2, 4, 3 | Fault |
9 | 2 | 2, 4, 3 | Hit |
10 | 3 | 2, 4, 3 | Hit |
11 | 0 | 2, 0, 3 | Fault |
12 | 3 | 2, 0, 3 | Hit |
13 | 2 | 2, 0, 3 | Hit |
14 | 1 | 2, 0, 1 | Fault |
15 | 2 | 2, 0, 1 | Hit |
16 | 0 | 2, 0, 1 | Hit |
17 | 1 | 2, 0, 1 | Hit |
18 | 7 | 7, 0, 1 | Fault |
19 | 0 | 7, 0, 1 | Hit |
20 | 1 | 7, 0, 1 | Hit |
Counting the Hits
Hits occur at:
5, 7, 9, 10, 12, 13, 15, 16, 17, 19, 20
Therefore, the total number of hits is: 11
Total number of page references: 20
Thus, the hit ratio is:
Information Booster
1. Optimal Page Replacement replaces the page that will be referenced farthest in the future.
2. It produces the minimum possible number of page faults for a given reference string.
3. Hit ratio is:
4. Page-fault ratio is:
5. For this problem:
Additional Knowledge
Since:
we have:
11 + 9 = 20
Therefore:
and the page-fault ratio is: