Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is fadvise/madvise equivalent on windows?

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 ?

like image 696
Steve Schnepp Avatar asked Jul 29 '09 15:07

Steve Schnepp


3 Answers

Beginning with Windows 8, there is the PrefetchVirtualMemory function for this purpose.

like image 64
Ben Voigt Avatar answered Nov 14 '22 19:11

Ben Voigt


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 :

  • 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.
like image 30
Steve Schnepp Avatar answered Nov 14 '22 19:11

Steve Schnepp


You can pass FILE_FLAG_RANDOM_ACCESS or FILE_FLAG_SEQUENTIAL_SCAN to CreateFile()

like image 5
Anders Avatar answered Nov 14 '22 18:11

Anders