HP-UX Reference (11i v3 07/02) - 2 System Calls (vol 5)
m
msync(2) msync(2)
NAME
msync() - synchronize the memory of a mapped file with physical storage
SYNOPSIS
#include <sys/mman.h>
int msync(
void *
addr,
size_t
len,
int
flags
);
Parameters
addr With len, specifies the region to be synchronized.
len With addr, specifies the region to be synchronized.
flags Specifies one of the following values:
MS_ASYNC
Performs asynchronous writes. The function synchronizes the file contents to match
the current contents of the memory region. If flags is MS_ASYNC, the function may
return immediately once all write operations have been scheduled.
• All write references to the memory region made prior to the call are visible by sub-
sequent read operations on the file.
• It is unspecified whether writes to the same portion of the file prior to the call are
visible by read references to the memory region.
• It is unspecified whether unmodified pages in the specified range are also written
to the underlying hardware.
MS_SYNC
Performs synchronous writes. The function synchronizes the file contents to match
the current contents of the memory region. If flags is MS_SYNC, the function does
not return until all write operations are completed.
• All write references to the memory region made prior to the call are visible by sub-
sequent read operations on the file.
• It is unspecified whether writes to the same portion of the file prior to the call are
visible by read references to the memory region.
• It is unspecified whether unmodified pages in the specified range are also written
to the underlying hardware.
MS_INVALIDATE
Invalidates mappings. The function synchronizes the contents of the memory region
to match the current file contents.
• All writes to the mapped portion of the file made prior to the call are visible by sub-
sequent read references to the mapped memory region.
• It is unspecified whether write references prior to the call, by any process, to
memory regions mapped to the same portion of the file using MAP_SHARED , are
visible by read references to the region.
DESCRIPTION
The msync() function writes all modified copies of pages over the range [addr, addr+len] to the underly-
ing hardware, or invalidates any copies so that further references to the pages will be obtained by the sys-
tem from their permanent storage locations.
addr and len specify the region to be synchronized. If these are not the address and length of a region
created by a previous successful call to mmap(), msync() returns an error. The behavior of msync()
upon a region created with the MAP_ANONYMOUS or MAP_PRIVATE flags is undefined.
If msync() causes any write to the file, then the file’s st_ctime and st_mtime fields are marked for update.
246 Hewlett-Packard Company − 1 − HP-UX 11i Version 3: February 2007