All mock tests are FREE till 31 December — register to save your progress

For the reference string: (given that number of frames is 3)
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
for the optimal page replacement algorithm, which of the following will represent the hit ratio?

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: A. 11/20

Explanation

Simulating OPT with 3 frames on this 20-reference string: references 7, 0, 1 fault to fill the initially empty frames. At reference 2 (position 4), OPT evicts 7 because, among the resident pages, 7 is used farthest in the future (position 18); at reference 3 (position 6) it evicts 1 (next used at position 14); at reference 4 (position 8) it evicts 0 (next used at position 11); at reference 0 (position 11) it evicts 4, which is never referenced again; at reference 1 (position 14) it evicts 3, which is never referenced again; and at reference 7 (position 18) it evicts 2, which is never referenced again. Counting carefully gives exactly 9 faults (positions 1,2,3,4,6,8,11,14,18) and therefore 11 hits out of 20, so the hit ratio is 11/20.

More System Software and Operating System questions