Files
seta75D ff309bfe1c Init
2021-10-11 18:37:13 -03:00

104 lines
1.9 KiB
Groff

.\" @(#)msync.2 1.1 94/10/31 SMI;
.TH MSYNC 2 "21 January 1990"
.SH NAME
msync \- synchronize memory with physical storage
.SH SYNOPSIS
.nf
.ft B
#include <sys/mman.h>
.ft
.fi
.LP
.nf
.ft B
int msync(addr, len, flags)
caddr_t addr;
int len, flags;
.ft R
.fi
.SH DESCRIPTION
.IX "msync()" "" "\fLmsync()\fP \(em synchronize memory with physical storage"
.LP
.B msync(\|)
writes all modified copies of pages over the range
[\fIaddr, addr + len\fP\^)
to their permanent storage locations.
.B msync(\|)
optionally invalidates any copies so that further references to the pages
will be obtained by the system from their permanent
storage locations.
.LP
Values for
.I flags
are defined in
.B <sys/mman.h>
as:
.LP
.RS
.nf
.ta 25n 35n
.ft B
#define \s-1MS_ASYNC\s0 0x1 /* Return immediately */
#define \s-1MS_INVALIDATE\s0 0x2 /* Invalidate mappings */
.ft R
.fi
.RE
.LP
and are used to control the behavior of
.BR msync(\|) .
One or more flags may
be specified in a single call.
.LP
.SB MS_ASYNC
returns
.B msync(\|)
immediately once all I/O operations are
scheduled; normally,
.B msync(\|)
will not return until all I/O operations are complete.
.SB 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.
.LP
.B msync(\|)
should be used by programs which require a memory object to
be
in a known state, for example in building transaction facilities.
.SH RETURN VALUES
.LP
.B msync(\|)
returns:
.TP
0
on success.
.TP
\-1
on failure and sets
.B errno
to indicate the error.
.SH ERRORS
.TP 15
.SM EINVAL
.I addr
is not a multiple of the current page size.
.IP
.I len
is negative.
.IP
One of the flags
.SB MS_ASYNC
or
.SB MS_INVALID
is invalid.
.TP
.SM EIO
An I/O error occurred while reading from or writing to the file system.
.TP
.SM ENOMEM
Addresses in the range
[\fIaddr, addr + len\fP\^)
are outside the valid range for
the address space of a process.