Is it possible for a FIFO page-replacement strategy to outperform LRU?

牧云@^-^@ 提交于 2019-12-12 19:17:24

问题


As part of my operating systems homework, I was asked to compare the number of page faults produced by first-in-first-out and least-recently-used page-replacement strategies for a given sequence of page accesses. Perplexingly, it appears that FIFO produced fewer page faults than LRU. Is this possible, or have I made a mistake?


回答1:


Yes, it's possible for FIFO to beat LRU. The smallest example I can think of,

Cache size: 2 pages.

Access pattern: A, B, A, C

After that, the LRU cache contains "A, C", whereas the FIFO cache contains "B, C". They have each missed 3 times so far. So if the next page access is "B", then FIFO beats LRU. If it's "A", LRU beats FIFO. If it's anything else, they remain tied.




回答2:


It's kind of difficult to give you a hint without giving you the answer. Why don't you try setting the question for yourself ? Put yourself in the mind of your teacher, a twisted dark place, and try setting the question in such a way as will make your (fellow) students think deeply about this.



来源:https://stackoverflow.com/questions/9569768/is-it-possible-for-a-fifo-page-replacement-strategy-to-outperform-lru

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!