title: Platform independent memory mapped [file] IO
body: <p>I've spent some time investigating memory mapped IO for an application I'm working on.  I have some very large (TB scale) files, and I want to map segments from them into memory, for both reading and writing, making maximum use of OS-level caching.  The software I'm writing needs to work under Unix/Linux and Windows... performance is critical.</p>
  
  <p>I've discovered <code>boost::iostreams::mapped_file_source</code> and <code>boost::iostreams::mapped_file_sink</code>, which provide most of the facilities I'm looking for.  The facilities I'd like, but haven't found are:</p>
  
  <ul>
  <li>Forcing a synchronisation of written data to disk ( <code>msync</code>(2) on Unix; <code>FlushViewOfFile</code> on Windows)</li>
  <li>Locking of files to prevent two processes attempting to write the same file at the same time (or read while the file is still being written..)</li>
  <li>Controlling attributes of the file at creation time (Unix)</li>
  </ul>
  
  <p>Can I do these things using <code>"boost/iostreams/device/mapped_file.hpp"</code>?  Are there other platform independent libraries that would better suit my requirements?  Must I develop my own cross-platform library to get this flexibility?</p>