📜  门| GATE-CS-2014-(Set-1) |第 65 题

📅  最后修改于: 2021-09-27 05:52:35             🧑  作者: Mango

假设有 3 个初始为空的页框。如果页面引用字符串为 1, 2, 3, 4, 2, 1, 5, 3, 2, 4, 6,则使用最优替换策略的缺页次数为__________。
(一) 5
(乙) 6
(三) 7
(四) 8答案: (C)
说明:在最优页面替换替换策略中,我们替换未来最长持续时间不使用的地方。

Given three page frames.

Reference string is 1, 2, 3, 4, 2, 1, 5, 3, 2, 4, 6

Initially, there are three page faults and entries are
1  2  3

Page 4 causes a page fault and replaces 3 (3 is the longest
distant in future), entries become
1  2  4
Total page faults =  3+1 = 4

Pages 2 and 1 don't cause any fault.

5 causes a page fault and replaces 1, entries become
5  2  4
Total page faults =  4 + 1 = 5

3 causes a page fault and replaces 5, entries become
3  2  4
Total page faults =  5 + 1 = 6

3, 2 and 4 don't cause any page fault.

6 causes a page fault.
Total page faults =  6 + 1 = 7

这个问题的测验