How can I tell Linux to keep a page and not evict it? [duplicate]

你。 提交于 2019-12-06 15:51:39

问题


Possible Duplicate:
Can I tell Linux not to swap out a particular processes' memory?

I want to allocate a chunk of memory in Linux and be sure that it will get no #GP or #PF faults. Regarding #GP, it's my responsibility as a programmer to ensure that I do not exceed any bounds. However, #PF are the the responsibility of the OS, since it can choose whether or not to evict a page.

I imagine that if I use the same page frequently, the OS will be smart enough not to evict it. However, if I want to allocate a large block of memory, then it'll take me a while to reach some of the pages, and I don't want the OS to evict it in the meanwhile.

Is there any way to tell Linux to keep a page present so that I never get a page fault?

Note: This is similar to to the question How can I tell Windows to keep a page and not evict it? except that this one is about Linux


回答1:


I think you are looking for mlock.



来源:https://stackoverflow.com/questions/7242168/how-can-i-tell-linux-to-keep-a-page-and-not-evict-it

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