在页面上发出 asnyc I/O
我想知道在已换出的页面上发出异步读取操作的正确方法是什么。一旦完成,有没有办法执行发生的回调,以便我可以在该页面上执行一些逻辑?
I was wondering what the correct way of issuing an asynchronous read operation on a page that has been swapped out is. And once this is done is there a way to execute a callback that happens so that I can execute some logic with that page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
madvise(start_address, length, MADV_WILLNEED)
会做到这一点。回调实际上并不存在,但如果需要,您可以使用
mincore
系统调用轮询状态快照。请注意,相反的提示
MADV_DONTNEED
不会不按照您的想法执行操作,msync
也不会执行此操作。文档在撒谎。在 Linux 下,没有一种非设计性的方式来启动异步回写(尽管文档是这么说的)。您可以选择无操作、丢弃页面、同步写回或异步写回并清除缓存。
madvise(start_address, length, MADV_WILLNEED)
will do that.A callback does not really exist, though you can poll a snapshot of the status with the
mincore
syscall, if you want.Note that the opposite hint
MADV_DONTNEED
does not do what you think, nor doesmsync
. The documentation is lying.There is no non-broken-by-design way to start asynchronous writeback under Linux (although the documentation says so). You can choose between no-op, throwing pages away, synchronous writeback, or asynchronous writeback with purging the cache.