2 .\" Copyright 1989 AT&T Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\" This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH MSYNC 3C "Jul 24, 2002"
12 msync \- synchronize memory with physical storage
18 \fBint\fR \fBmsync\fR(\fBvoid *\fR\fIaddr\fR, \fBsize_t\fR \fIlen\fR, \fBint\fR \fIflags\fR);
24 The \fBmsync()\fR function writes all modified copies of pages over the range
25 [\fIaddr, addr + len\fR) to the underlying hardware, or invalidates any copies
26 so that further references to the pages will be obtained by the system from
27 their permanent storage locations. The permanent storage for a modified
28 \fBMAP_SHARED\fR mapping is the file the page is mapped to; the permanent
29 storage for a modified \fBMAP_PRIVATE\fR mapping is its swap area.
32 The \fIflags\fR argument is a bit pattern built from the following values:
39 perform asynchronous writes
48 perform synchronous writes
62 If \fIflags\fR is \fBMS_ASYNC\fR or \fBMS_SYNC\fR, the function synchronizes
63 the file contents to match the current contents of the memory region.
68 All write references to the memory region made prior to the call are visible by
69 subsequent read operations on the file.
75 All writes to the same portion of the file prior to the call may or may not be
76 visible by read references to the memory region.
82 Unmodified pages in the specified range are not written to the underlying
87 If \fIflags\fR is \fBMS_ASYNC\fR, the function may return immediately once all
88 write operations are scheduled; if \fIflags\fR is \fBMS_SYNC\fR, the function
89 does not return until all write operations are completed.
92 If \fIflags\fR is \fBMS_INVALIDATE\fR, the function synchronizes the contents
93 of the memory region to match the current file contents.
98 All writes to the mapped portion of the file made prior to the call are visible
99 by subsequent read references to the mapped memory region.
105 All write references prior to the call, by any process, to memory regions
106 mapped to the same portion of the file using \fBMAP_SHARED\fR, are visible by
107 read references to the region.
111 If \fBmsync()\fR causes any write to the file, then the file's \fBst_ctime\fR
112 and \fBst_mtime\fR fields are marked for update.
116 Upon successful completion, \fBmsync()\fR returns \fB0\fR; otherwise, it
117 returns \fB\(mi1\fR and sets \fBerrno\fR to indicate the error.
121 The \fBmsync()\fR function will fail if:
128 Some or all of the addresses in the range [\fIaddr\fR, \fIaddr\fR + \fIlen\fR)
129 are locked and \fBMS_SYNC\fR with the \fBMS_INVALIDATE\fR option is specified.
138 Some or all pages in the range [\fIaddr\fR, \fIaddr\fR + \fIlen\fR) are
148 The \fIaddr\fR argument is not a multiple of the page size as returned by
151 The \fIflags\fR argument is not some combination of \fBMS_ASYNC\fR and
161 An I/O error occurred while reading from or writing to the file system.
170 Addresses in the range [\fIaddr, addr + len\fR) are outside the valid range for
171 the address space of a process, or specify one or more pages that are not
181 \fBMS_INVALIDATE\fR was specified and one or more of the pages is locked in
188 The \fBmsync()\fR function should be used by programs that require a memory
189 object to be in a known state, for example in building transaction facilities.
192 Normal system activity can cause pages to be written to disk. Therefore, there
193 are no guarantees that \fBmsync()\fR is the only control over when pages are or
194 are not written to disk.
198 See \fBattributes\fR(5) for descriptions of the following attributes:
206 ATTRIBUTE TYPE ATTRIBUTE VALUE
208 Interface Stability Standard
216 \fBmemcntl\fR(2), \fBmmap\fR(2), \fBsysconf\fR(3C), \fBattributes\fR(5),