FlushViewOfFile, lazy writing, cache manager
From: Martin Kochanski (nothing_at_nobody.net)
Date: 03/09/04
- Next message: Slava M. Usov: "Re: FlushViewOfFile, lazy writing, cache manager"
- Previous message: Hari: "Re: Using Lists"
- Next in thread: Slava M. Usov: "Re: FlushViewOfFile, lazy writing, cache manager"
- Reply: Slava M. Usov: "Re: FlushViewOfFile, lazy writing, cache manager"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 09 Mar 2004 11:59:52 +0000
If I open a file under Windows XP, create a memory-mapped view of it,
alter a few bytes somewhere in the middle of it, go out to lunch and
come back to find there's been a crash or a power failure, then the
altered bytes have not been written to the disk. Either there isn't a
built-in lazy writer thread for dirty pages that are backed by a user
file, or it isn't working (or it's very lazy indeed).
At first sight FlushViewOfFile would appear to be the solution to this
problem, since it is documented as flushing out dirty pages to the disk.
However, a more detailed look at the documentation shows that this is
exactly what FlushViewOfFile does not do. Instead it passes dirty pages
out to the Windows cache manager, which at some undetermined time in the
future may get its lazy writer to write them out. (I am aware that this
can be circumvented by FILE_FLAG_WRITE_THROUGH, but that has other
disadvantages).
So my first question is: does the cache manager's lazy writer write out
pages in any reasonable time, or will they sit there in physical RAM,
marked as dirty, for hours?
The other question is whether any of this actually applies to Windows
XP. One of the claims made for the architectural changes in XP is that
there is now a single memory manager, so that, for example, "cache
coherency with user mapped files is free" (this is a quote from a MS
presentation).
If this is the case, it seems that there should be no difference between
the dirty page being in user mapped memory and in the cache manager's
mapped memory, so that FlushViewOfFile effectively becomes a no-op. My
second question, then, is: in Windows XP (without
FILE_FLAG_WRITE_THROUGH) does FlushViewOfFile do anything at all, and,
if so, what?
- Next message: Slava M. Usov: "Re: FlushViewOfFile, lazy writing, cache manager"
- Previous message: Hari: "Re: Using Lists"
- Next in thread: Slava M. Usov: "Re: FlushViewOfFile, lazy writing, cache manager"
- Reply: Slava M. Usov: "Re: FlushViewOfFile, lazy writing, cache manager"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|