我怎样才能告诉 Linux 保留一个页面而不是驱逐它?
我想在 Linux 中分配一块内存,并确保它不会出现 #GP 或 #PF 错误。关于#GP,作为一名程序员,我有责任确保我不超出任何界限。然而,#PF 是操作系统的责任,因为它可以选择是否驱逐页面。
我想,如果我经常使用同一页面,操作系统将足够聪明,不会驱逐它。但是,如果我想分配一大块内存,那么我需要一段时间才能到达某些页面,并且我不希望操作系统同时驱逐它。
有没有办法告诉Linux保持页面存在,这样我就不会出现页面错误?
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您正在寻找
mlock< /代码>
。
I think you are looking for
mlock
.