msync

NAME

msync() - write pages to storage, synchronizing memory

SYNOPSIS

int msync (void *addr, size_t len, int flags)

DESCRIPTION

Depending on the flags argument, the msync(3) call writes to storage all modified pages over the range addr to addr+len or invalidates the existing copies of those pages so that future references to the page come from permanent storage. The flags argument can be one of:

MS_ASYNC
Write current memory contents asynchronously. After this call, all reads can read any writes made to the memory region before the call, and the call returns after scheduling the write.
MS_SYNC
Write current memory contents synchronously. After this call, all reads can read any writes made to the memory region before the call, and the call does not return until the write is completed.
MS_INVALIDATE
Invalidate existing page mappings. Essentially this makes the memory mapping look like the last-saved state of the file, rather than the other way around. The memory region will contain all writes made to the mapped portion of the file before the call.

DIAGNOSTICS

The msync(3) call returns 0 for success and returns -1 otherwise. If it does not succeed, it sets errno to indicate the error.

ERRORS

The msync(3) call can fail for the following reasons:

[EINVAL]
The addr argument is not a multiple of the page size; use sysconf(2) to determine the page size.
[EIO]
An I/O error occurred.
[ENOEM]
An address in the range [addr, addr + len] was not valid for the process or those pages aren't mapped.

SEE ALSO

mmap(2)

sysconf(2)