问题:
考虑以下页面引用字符串: 1,2,3,4,2,1,5,6,2,1,2,3,7,6,3,2,1,2,3,6。
假设有五个帧,最佳页面替换算法会发生多少次页面错误?请记住,所有帧最初都是空的,因此您的第一个唯一页面每个都会花费一个故障。
我不太确定会发生什么:
1 -> 1
2 -> 1, 2
3 -> 1, 2, 3
4 -> 1, 2, 3, 4,
2 -> What happens here??
1
...etc (with the rest of the reference string)
答案 0 :(得分:1)
总共会有7页错误。
1 -> 1
2 -> 1, 2
3 -> 1, 2, 3
4 -> 1, 2, 3, 4
2 -> 1, 2, 3, 4 (This is a hit 2 is already in the memory)
1 -> 1, 2, 3, 4
5 -> 1, 2, 3, 4, 5 (This is a miss but we have 5 frames.)
6 -> 1, 2, 3, 6, 5 (4 will be replaced as it is not required in future)
...