Do you mean even if I only invoke write API (without flush) when in
FILE_FLAG_WRITE_THROUGH mode, the OS buffer and the physical content on disk
are the same?
Almost. if FILE_FLAG_NO_BUFFERING is in effect, the write operation will go
through the cache and writes directly to the hard disk.
If that flag is not used, write operations go to the system cache but get
flushed immediately. This is a subtle difference and has to do only with
asynchronous performance characteristics. The data arrives on disk at almost
the same time. only the write operation finishes a bit earlier.
Another question is, if FILE_FLAG_WRITE_THROUGH mode is not enabled, how
will data lose? (I think if FILE_FLAG_WRITE_THROUGH is not enabled, we could
invoke flush, and whether or not FILE_FLAG_WRITE_THROUGH is enebled, flush
will definitely write OS buffer data to external disk. Is my understanding
correct?)
flush will definitely get your data to disk.
if you don't flush and the computer loses power or crashes, it is impossible
to predict how much data you lose.
Note that if your computer loses power before the hard disk internal cache
is written to disk, you will stil lose some data.
--
Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"