HP-UX Reference (11i v1 05/09) - 2 System Calls (vol 5)
m
msync(2) msync(2)
HP-UX EXTENSIONS
NAME
msync - synchronize a mapped file
SYNOPSIS
int msync(caddr_t addr,size_t len, int flags);
DESCRIPTION
msync controls the caching operations of a mapped file region.
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.
After a successful call to
msync() with
MS_SYNC specified, all previous modifications to the mapped
region are visible to processes using
read(). Previous modifications to the file using
write() may be
lost.
After a successful call to
msync() with only MS_INVALIDATE
specified, all previous modifications to
the file using
write() are visible to the mapped region. Previous direct modifications to the mapped
region may be lost.
Performance Considerations
The following performance considerations only apply when using the
MS_INVALIDATE option with
msync(). These performance constraints do not apply when either MS_ASYNC or MS_SYNC are
exclusively used with msync().
Direct read/write references to portions of a mapped memory region currently undergoing an
msync()
operation (with MS_INVALIDATE specified), may be blocked until all scheduled write operations are com-
pleted. This is especially true when performing an
msync() operation across a relatively large address
range that requires many individual write operations to be scheduled out to the underlying hardware. HP-
UX will schedule a separate write operation for each contiguous group of modified pages on disk. As more
write operations are queued out to the device, the overall suspension time of direct read/write references to
the same portions of the memory region will generally increase.
The suspension times of direct read/write references can be reduced by issuing
msync() requests over
smaller portions of the memory region, but issuing them more frequently than a corresponding larger syn-
chronization request. This will serve to more evenly distribute I/O activity across the mapped file, while
reducing the number of write operations per
msync().
ERRORS
[EINVAL] addr is not a multiple of the page size as returned by
sysconf(_SC_PAGE_SIZE)
.
[EINVAL] The address range specified by addr and len was not created by a successful call to
mmap().
AUTHOR
msync() was developed by HP, AT&T, and OSF.
SEE ALSO
mmap(2), sysconf(2), thread_safety(5).
STANDARDS CONFORMANCE
msync(): AES, SVID3
HP-UX 11i Version 1: September 2005 − 1 − Hewlett-Packard Company Section 2−−199