我正在尝试了解 FIFO 页面替换算法,但我能找到的所有信息都属于以下内容。您能解释一下如何使用引用字符串来评估页面替换算法,使用 FIFO 的特定示例吗?
When a page must be replaced, the oldest page is chosen.
In all our examples, the reference string is
1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
3 frame (9 page faults) 4 frame (10 page faults)
最佳答案
页面错误是指内存帧中不存在页面,因此必须向操作系统发送陷阱
并且页面必须添加到框架中。如果没有空间,则需要移除某些东西。
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
关于operating-system - FIFO 页面替换如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13834802/