The msync function controls the caching operations of a mapped
file region. Use msync to:
o Ensure that modified pages in the region transfer to the
underlying storage device of the file.
o Control the visibility of modifications with respect to file
system operations.
The addr and len arguments specify the region to be synchronized.
The len argument must be a multiple of the page size as returned
by sysconf(_SC_PAGE_SIZE); otherwise, the length of the region is
rounded up to the next multiple of the page size.
If the flags argument is set to:
flags Argument Then the msync Function...
MS_SYNC Does not return until the system completes all
I/O operations.
MS_ASYNC Returns after the system schedules all I/O
operations.
MS_INVALIDATE Invalidates all cached copies of the pages. The
operating system must obtain new copies of the
pages from the file system the next time the
application references them.
After a successful call to the msync function with the flags
argument set to:
o MS_SYNC - All previous modifications to the mapped region
are visible to processes using the read argument. Previous
modifications to the file using the write function are lost.
o MS_INVALIDATE - All previous modifications to the file using
the write function are visible to the mapped region. Previous
direct modifications to the mapped region are lost.
See also read, write, and sysconf.