评估 5 帧的最佳替换算法

Evaluate optimal replacement algorithm for 5 frames

问题:

考虑以下页面引用字符串: 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)

总共会出现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)
...