title: Atomic writes in linux
body: <p>On linux, when writing to a pipe, if the data is equal or less than the memory page size (4k atleast on 64bit rhel), the OS provides the guarantee that the whole write will either succeed or fail, but there would be no corruption of data, when multiple process are doing write at the same time. This applies to writing to regular files also.</p>
  
  <ol>
  <li><p>My question is that is this atomicity a feature of virtual memory of linux? If yes, consider  a shared memory scenario between two process, where one process is swapped out in middle of the write by the scheduler. Does Virtual memory subsytem ensures that the memory page to which the process was writing, is also locked, so that the second process cannot write to the same page?</p></li>
  <li><p>Is this atomicity at page level only applicable across process , or also between threads of the same process? </p></li>
  </ol>