title: How does Windows deal with flushing modified pages in a consistent way?
body: <p>Imagine there's a memory-mapped file and the application is writing to it constantly. Eventually, Windows will probably flush that page to disk. How does Windows ensure that a stable snapshot of that page is flushed to disk?</p>
  
  <p>Probably, the disk hardware is copying the memory into it's internal memory before writing it. That's not atomic. If the application writes randomly to that page the disk hardware might copy data that has never existed at any point in time.</p>
  
  <p>Does this mean that memory mapped files might leave a page on disk in a state that has never actually existed? That could be a problem to consistency.</p>
  
  <p>Or does Windows lock the page during flushing? That could be a problem because a write to that page might result in very high latency.</p>