windows上的fadvise/madvise等价物是什么? [英] What is fadvise/madvise equivalent on windows?
本文介绍了windows上的fadvise/madvise等价物是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,在 UNIX 上,我可以使用 posix_fadvise(POSIX_FADV_WILLNEED)
告诉操作系统将来需要映射.然后它会根据需要预读数据.
On UNIX, I can, for example, tell the OS that the mapping will be needed in the future with posix_fadvise(POSIX_FADV_WILLNEED)
. It will then read-ahead the data if it feels so.
如何判断对Windows的访问?
How to tell the access intend to Windows ?
推荐答案
实际上,正如 Anders 主要建议的那样,在 Windows 7 及更早版本中可用的内存管理功能中没有这种方法.
Actually, as Anders mostly suggested, there is no such method in the memory management functions available in Windows 7 and earlier.
存在两种不同的方法来做类似的事情:
2 different ways exists to do something similar :
- 使用 ReadFileEx 异步读取数据.以后需要时,数据可能仍在文件缓存中.
- 使用带有 创建文件.预读可能会自动完成.
- Read the data asynchronously with ReadFileEx. The data might then still be in the file cache when needed later.
- Open the file with a streaming hint with the
FILE_FLAG_SEQUENTIAL_SCAN
attribute of CreateFile. Readahead would then perhaps be automatically done.
这篇关于windows上的fadvise/madvise等价物是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文