msync.2 (2010 09)

m
msync(2) msync(2)
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
completed. 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
synchronization request. This will serve to more evenly distribute I/O activity across the mapped file,
while reducing the number of write operations per
msync().
RETURN VALUE
msync() returns the following values:
0 Successful completion.
-1 Failure. errno is set to indicate the error.
ERRORS
The
msync() function will fail if:
[EAGAIN] A transient error occurred while reading from or writing to the file system.
[EBUSY] Some or all of the addresses in the range starting at addr and continuing for
len bytes are locked, and
MS_INVALIDATE
is specified.
[EINVAL] The addr argument 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().
[EINVAL] The value of flags is invalid.
[EIO] An I/O error occurred while reading from or writing to the file system.
[ENOMEM] Some or all the addresses in the range [addr, addr+len] are invalid for the
address space of the process. Or, pages that are not mapped are specified.
APPLICATION USAGE
The
msync() function should be used by programs that require a memory object to be in a known state.
For example, in building transaction facilities.
Normal system activity can cause pages to be written to disk. Therefore, there are no guarantees that
msync() is the only control over when pages are or are not written to disk.
AUTHOR
msync() was developed by HP, AT&T, and OSF.
SEE ALSO
mmap(2), sysconf(2), <sys/mman.h>.
STANDARDS CONFORMANCE
msync(): AES, SVID3
CHANGE HISTORY
First released in Issue 4, Version 2.
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010