From: Hugo gleaves on
I think also that it is true to say that unless one uses
FILE_FLAG_WRITE_THROUGH then any calls made to FlushViewOfFile will return
BEFORE all data is flushed to the physical disk.

If you do use FILE_FLAG_WRITE_THROUGH then FlushViewOfFile will ONLY return
to call when all modified pages are definitely written to the physical media.

This is my understanding, and of course it is only important if one is doing
explicit flushes (I also seem to recall that in this case, we needed to also
use FILE_FLAG_NO_BUFFERING too, but I can't recall the details of this now.

H

"Pavel Lebedinsky [MSFT]" wrote:

> > Does FILE_FLAG_NO_BUFFERING makes any difference for
> > memory mapping? Isn't file caching and paging in done by memory
> > manager?
>
> The memory manager ignores the no-buffering flag. The flag is
> used by the cache manager and filesystems, and it's generally
> not recommended to mix cached/memory mapped IO and
> non-cached IO on the same file. Even just opening a file for
> non-cached access (without doing any actual IO) can have
> side effects in certain cases.
>
> > Or without the flag page-ins will be done from the file
> > cache (which I think won't)?
>
> If a file page is already resident in memory because it was
> fetched by a cached ReadFile call then yes, reading it through
> a user mapped view will just return the data from the cache.
> The system file cache is implemented using memory mapped
> files, so this is the same as reading the same page through
> two separate user views - only the first read will actually hit
> the disk.
>
> --
> Pavel Lebedinsky/Windows Kernel Test
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>