title: Replacing memory mappings atomically on Windows
body: <p>Is there any way to atomically replace a memory mapping on Windows?</p>
  
  <p>On Unix, mmap() with MAP_FIXED will atomically replace the page mapped at the requested address.</p>
  
  <p>But on Windows, MapViewOfFileEx() can't be used on an address if a page is already mapped there.  The existing page must first be unmapped, e.g. with UnmapViewOfFile().  This means there is a short period during which the address is unallocated, so if another thread creates a memory mapping concurrently it might be placed at this address.</p>
  
  <p>Is there an interface in Windows that gets around this problem, without modifying the kernel?  Perhaps using system calls directly?</p>