94 lines
2.5 KiB
Groff
94 lines
2.5 KiB
Groff
'\"macro stdmacro
|
|
.if n .pH g2.msync @(#)msync 40.15 of 1/3/91
|
|
.\" Copyright 1991 UNIX System Laboratories, Inc.
|
|
.\" Copyright 1989, 1990 AT&T
|
|
'\" ident "@(#)svid_rt:rt_os/msync 1.2"
|
|
.\" @(#)msync 1.4 88/09/26 SMI;
|
|
'\"macro stdmacro
|
|
.\" Sun's msync.3
|
|
.nr X
|
|
.if \nX=0 .ds x} msync 2 "" "\&"
|
|
.if \nX=1 .ds x} msync 2 ""
|
|
.if \nX=2 .ds x} msync 2 "" "\&"
|
|
.if \nX=3 .ds x} msync "" "" "\&"
|
|
.TH \*(x}
|
|
.SH NAME
|
|
\f4msync\f1 \- synchronize memory with physical storage
|
|
.SH SYNOPSIS
|
|
.ft 4
|
|
.nf
|
|
#include <sys/types.h>
|
|
#include <sys/mman.h>
|
|
.sp0.5
|
|
int msync(void \(**addr, size_t len, int flags);
|
|
.ft 1
|
|
.fi
|
|
.SH DESCRIPTION
|
|
The function \f4msync\f1
|
|
writes all modified copies of pages over the range
|
|
[\f2addr, addr + len\f1\^)
|
|
to their backing storage locations.
|
|
\f4msync\f1
|
|
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 \f4MAP_SHARED\fP mapping is the file
|
|
the page is mapped to;
|
|
the backing storage for a modified \f4MAP_PRIVATE\fP mapping is its swap area.
|
|
.P
|
|
\f2flags\f1
|
|
is a bit pattern built from the following values:
|
|
.P
|
|
.RS
|
|
.ta 25n 30n
|
|
.nf
|
|
\f4MS_ASYNC\f1 perform asynchronous writes
|
|
\f4MS_SYNC\f1 perform synchronous writes
|
|
\f4MS_INVALIDATE\f1 invalidate mappings
|
|
.fi
|
|
.RE
|
|
.P
|
|
If \f4MS_ASYNC\f1 is set, \f4msync\fP returns immediately once all write operations are scheduled;
|
|
if \f4MS_SYNC\f1 is set, \f4msync\fP does not return until all write operations are completed.
|
|
.P
|
|
\f4MS_INVALIDATE\f1 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.
|
|
.P
|
|
\f2msync\fP will fail if:
|
|
.TP 15
|
|
.SM
|
|
\%[EINVAL]
|
|
If \f2addr\fP is not a multiple of the page size as returned by
|
|
\f4sysconf\fP(3C).
|
|
.TP
|
|
.SM
|
|
\%[EIO]
|
|
An I/O error occurred while reading from or writing to the file system.
|
|
.TP
|
|
.SM
|
|
\%[ENOMEM]
|
|
Addresses in the range (\f2addr, addr + len\fP\^)
|
|
are outside the valid range for the address space of a process or
|
|
pages not mapped are specified.
|
|
.TP
|
|
.SM
|
|
\%[EBUSY]
|
|
.SM
|
|
.B MS_INVALIDATE
|
|
was specified and one or more of the pages
|
|
was locked in memory.
|
|
.SH SEE ALSO
|
|
\f4mmap\fP(2),
|
|
\f4mpin\fP(2),
|
|
\f4sysconf\fP(3C).
|
|
.SH DIAGNOSTICS
|
|
Upon successful completion, the function \f4msync\f1 returns
|
|
0; otherwise, it returns \-1 and
|
|
sets \f4errno\f1 to indicate the error.
|
|
.SH NOTES
|
|
\f4msync\f1
|
|
should be used by programs that require a memory object to
|
|
be
|
|
in a known state, for example, in building transaction facilities.
|