MSYNC(2) — SYSTEM CALLS
NAME
msync − synchronize memory with physical storage
SYNOPSIS
#include <sys/mman.h>
msync(addr, len, flags)
caddr_t addr;
int len, flags;
DESCRIPTION
msync() writes all modified copies of pages over the range [addr, addr + len) to their permanent storage locations. msync() optionally invalidates any copies so that further references to the pages will be obtained by the system from their permanent storage locations.
Values for flags are defined in /usr/include/sys/mman.h as:
#define MS_ASYNC0x1/∗ Return immediately ∗/
#define MS_INVALIDATE0x2 /∗ Invalidate mappings ∗/
and are used to control the behavior of msync. One or more flags may be specified in a single call.
MS_ASYNC returns msync() immediately once all I/O operations are scheduled; normally, msync() will not return until all I/O operations are complete. MS_INVALIDATE invalidates all cached copies of data from memory objects, requiring them to be re-obtained from the object’s permanent storage location upon the next reference.
msync() should be used by programs which require a memory object to be in a known state, for example in building transaction facilities.
RETURN VALUE
A 0 value is returned on success. A −1 value indicates an error.
ERRORS
msync() fails if:
EIO An I/O error occurred while reading from or writing to the file system.
ENOMEM Addresses in the range [addr, addr + len) are outside the valid range for the address space of a process.
EINVAL Either addr is not a multiple of the current page size, or len is negative.
EINVAL One of the flags MS_ASYNC or MS_INVALID is invalid.
Sun Release 4.0 — Last change: 22 March 1989