views:

293

answers:

3

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.

How to tell the access intend to Windows ?

+1  A: 

You can pass FILE_FLAG_RANDOM_ACCESS or FILE_FLAG_SEQUENTIAL_SCAN to CreateFile()

Anders
Are that the only hinting possibilities on Windows ?
Steve Schnepp
As far as hints go, I think so. You can disable caching and things like that, but some of those other flags have alignment requirements so its more than a simple hint
Anders
A: 

Actually, as Anders mostly suggested, there is no such method in the memory management functions.

2 different ways exists to do something similar :

  • 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.
Steve Schnepp
A: 

Steve/Anders, that may be fine when you are reading files, but what about memory mapped regions? I can't see any equivalent to madvise(, , MADV_WILLNEED) ...

Michael Fuller
As I said, it seems that only workarounds exist : *no such method in the mm functions*.
Steve Schnepp