6

我正在尝试了解 FIFO 页面替换算法,但我能找到的所有信息都属于以下内容。您能解释一下如何使用参考字符串来评估页面替换算法,使用 FIFO 的特定示例吗?

当必须替换页面时,将选择最旧的页面。

在我们所有的例子中,参考字符串是

1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5

3 帧(9 个页面错误) 4 帧(10 个页面错误)

4

4 回答 4

10

页面错误是指内存帧中不存在页面,因此必须向操作系统发送陷阱并且必须将页面添加到帧中。如果没有空间,则需要移除某些东西。FIFO 是一种确定要删除哪个页面的方法。

这个概念是,首先添加到框架中的任何页面都将首先被删除。这就是 FIFO 的含义。使用你的第一个例子。我将查看参考字符串列表,并向您展示内存的外观。

1:  1      +1 fault
2:  1,2    +1 fault
3:  1,2,3  +1 fault
4:  2,3,4  +1 fault - 1 gets removed because it was the first added
1:  3,4,1  +1 fault - 2 gets removed because it was the first on the list
2:  4,1,2  +1 fault - 3 got removed..
5:  1,2,5  +1 fault - 4 got removed..
1:  1,2,5  No change - 1 is already present so no page fault was required
2:  1,2,5  No change - 2 is already present in the frame
3:  2,5,3  +1 fault - 1 was removed because it is first
4:  5,3,4  +1 fault - Now 2 got removed
5:  5,3,4  No change - No change because 5 is present in one of the frames.

这给出了总共 9 个故障。

您也可以将其视为最旧的页面被删除。

希望我没有犯错:D

于 2013-11-09T22:35:21.910 回答
4

------------ * 先进先出 * -------------

Page no. 1 |   1 +1

Page no. 2 |   1 2 +1

Page no. 3 |   1 2 3 +1

Page no. 4 |   1 2 3 4 +1

Page no. 1 |  

Page no. 2 |  

Page no. 5 |   2 3 4 5 +1

Page no. 1 |   3 4 5 1 +1

Page no. 2 |   4 5 1 2 +1

Page no. 3 |   5 1 2 3 +1

Page no. 4 |   1 2 3 4 +1

Page no. 5 |   2 3 4 5 +1


Page Faults = 10
于 2014-02-06T06:45:56.397 回答
3

队列中不可用时替换页面。

去这个链接FIFO

这里解释了所有 Page repalacemnt 算法。很好的例子。你很容易理解。

于 2012-12-12T07:33:04.743 回答
-2
1:  1      +1 fault
2:  1,2    +1 fault
3:  1,2,3  +1 fault
4:  2,3,4  +1 fault - 1 gets removed because it was the first added
1:  3,4,1  +1 fault - 2 gets removed because it was the first on the list
2:  4,1,2  +1 fault - 3 got removed..
5:  1,2,5  +1 fault - 1 got removed..
1:  1,2,5  No change - 1 is already present so no page fault was required
2:  1,2,5  No change - 2 is already present in the frame
3:  2,5,3  +1 fault - 1 was removed because it is first
4:  5,3,4  +1 fault - Now 2 got removed
5:  5,3,4  No change - No change because 5 is present in one of the frames.
于 2015-08-14T09:27:54.053 回答