DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

msync(S)


msync -- synchronize memory mapping with physical storage

Syntax

cc . . . -lc
#include <sys/types.h>
#include <sys/mman.h>

int msync(caddr_t addr, size_t len, int flags);

Description

The function msync writes all modified copies of pages over the range [addr, addr + len] to their backing storage locations. msync optionally invalidates any copies so that further references to the pages will be obtained by the system from their backing storage locations. The backing storage for a modified MAP_SHARED mapping is the file the page is mapped to; the backing storage for a modified MAP_PRIVATE mapping is its swap area.

flags is a bit pattern built from the following values:


MS_ASYNC
perform asynchronous writes

MS_SYNC
perform synchronous writes

MS_INVALIDATE
invalidate mappings
If MS_ASYNC is set, msync returns immediately once all write operations are scheduled; if MS_SYNC is set, msync does not return until all write operations are completed.

MS_INVALIDATE invalidates all cached copies of data in memory, so that further references to the pages will be obtained by the system from their backing storage locations.

msync should be used by programs that require a memory object to be in a known state, for example, in building transaction facilities.

Return values

Upon successful completion, the function msync returns 0; otherwise, it returns -1 and sets errno to indicate the error.

Diagnostics

Under the following conditions, the function msync fails and sets errno to:

EBUSY
if some or all the addresses in the range [addr, addr + len] are locked and MS_INVALIDATE is specified.

[EINVAL]
if addr is not a multiple of the page size as returned by sysconf(S), or the value in flags is invalid.

[ENOMEM]
if some or all the addresses in the range [addr, addr + len] are invalid for the address space of the process or pages not mapped are specified.

Files


/lib/libc.a
linking library

See also

mmap(S), sysconf(S)

Standards conformance

msync is conformant with:

AT&T SVID Issue 3;
IEEE POSIX Std 1003.4 1992 System Application Program Interface (API) Realtime Extension [C Language] (ISO/IEC 9945-1).


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003