1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (C) 1996 Andries Brouwer (aeb@cwi.nl)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
26 .\" all rights reserved.
27 .\" Translated Sun Feb 23 19:45:43 JST 1997
28 .\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
29 .\" Updated and revised Fri Oct 24 23:34:51 JST 2003
30 .\" by Suzuki Takashi.
31 .\" Updated 2007-01-01 by Kentaro Shirakata <argrath@ub32.org>
33 .\"WORD: in-core ¥á¥â¥ê¾å¤Î
35 .TH MSYNC 2 2008-04-22 "Linux" "Linux Programmer's Manual"
38 .\"O msync \- synchronize a file with a memory map
39 msync \- ¥Õ¥¡¥¤¥ë¤ò¥Þ¥Ã¥×¤·¤¿¥á¥â¥ê¤ÈƱ´ü¤µ¤»¤ë
42 .B #include <sys/mman.h>
44 .BI "int msync(void *" addr ", size_t " length ", int " flags );
48 .\"O flushes changes made to the in-core copy of a file that was mapped
49 .\"O into memory using
52 .\"O Without use of this call
53 .\"O there is no guarantee that changes are written back before
56 .\"O To be more precise, the part of the file that
57 .\"O corresponds to the memory area starting at
59 .\"O and having length
65 ¤ò»È¤Ã¤Æ¥á¥â¥ê¤Ë¥Þ¥Ã¥×¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Î¡¢
66 ¥á¥â¥ê¾å¤Î¥³¥Ô¡¼¤Ë¤Ê¤µ¤ì¤¿Êѹ¹¤ò¥Ç¥£¥¹¥¯¤ËÈ¿±Ç¤µ¤»¤ë¡£
67 ¤³¤Î´Ø¿ô¤ò»ÈÍѤ·¤Ê¤¤¤È¡¢
69 ¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤Þ¤ÇÊѹ¹¤¬½ñ¤Ìᤵ¤ì¤ëÊݾڤϤʤ¤¡£
70 ¤è¤êÀµ³Î¤Ë¤Ï¡¢¥Õ¥¡¥¤¥ë¤Î¤¦¤Á
74 ¤Î¥á¥â¥êÎΰè¤ËÂбþ¤¹¤ëÉôʬ¤¬¹¹¿·¤µ¤ì¤ë¡£
78 .\"O argument may have the bits
83 .\"O set, but not both
92 ¤òÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤¤ë¤¬¡¢
96 ¤òƱ»þ¤Ë»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
98 .\"O specifies that an update be scheduled, but the call
99 .\"O returns immediately.
101 ¤Ï¹¹¿·¤òͽÄê¤ËÁȤ߹þ¤à¤³¤È¤òɽ¤·¡¢¸Æ¤Ó½Ð¤·¤Ïľ¤Á¤ËÊ֤롣
103 .\"O asks for an update and waits for it to complete.
105 ¤Ï¹¹¿·¤òÍ׵ᤷ¡¢¹¹¿·¤¬´°Î»¤¹¤ë¤Þ¤ÇÂԤġ£
106 .\"O .B MS_INVALIDATE
107 .\"O asks to invalidate other mappings of the same file
108 .\"O (so that they can be updated with the fresh values just written).
110 ¤Ï(¤¿¤Ã¤¿º£½ñ¤¹þ¤ó¤À¿·¤·¤¤Ãͤǥޥåԥ󥰤ò¹¹¿·¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¤è¤¦¤Ë)
111 Ʊ¤¸¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ë¾¤Î¥Þ¥Ã¥Ô¥ó¥°¤ò̵¸ú¤Ë¤¹¤ë¤³¤È¤òÍ׵᤹¤ë¡£
112 .\"O .SH "RETURN VALUE"
114 .\"O On success, zero is returned.
115 .\"O On error, \-1 is returned, and
117 .\"O is set appropriately.
118 À®¸ù¤·¤¿¾ì¹ç¡¢ 0 ¤¬Ê֤롣¥¨¥é¡¼¤Î¾ì¹ç¡¢ \-1 ¤¬Ê֤ꡢ
125 .\"O .B MS_INVALIDATE
126 .\"O was specified in
128 .\"O and a memory lock exists for the specified address range.
132 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢»ØÄꤵ¤ì¤¿¥¢¥É¥ì¥¹ÈϰϤ˥í¥Ã¥¯¤¬Â¸ºß¤¹¤ë¡£
136 .\"O is not a multiple of PAGESIZE; or any bit other than
137 .\"O .BR MS_ASYNC " | " MS_INVALIDATE " | " MS_SYNC
147 ¤¬ PAGESIZE ¤ÎÇÜ¿ô¤Ç¤Ê¤¤¡£¤Þ¤¿¤Ï¡¢
150 .BR MS_ASYNC ¡¢ MS_INVALIDATE ¡¢ MS_SYNC
151 °Ê³°¤Î¥Ó¥Ã¥È¤¬ÀßÄꤵ¤ì¤¿¡£
161 .\"O The indicated memory (or part of it) was not mapped.
162 »ØÄꤵ¤ì¤¿¥á¥â¥ê (¤Þ¤¿¤Ï¤½¤Î°ìÉô) ¤¬¥Þ¥Ã¥×¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
163 .\"O .SH "CONFORMING TO"
167 .\"O This call was introduced in Linux 1.3.21, and then used
171 .\"O In Linux 2.4.19 this was changed to the POSIX value
173 ¤³¤Î´Ø¿ô¤Ï Linux 1.3.21 ¤ÇƳÆþ¤µ¤ì¤¿¤¬¡¢
178 ¤³¤ì¤Ï Linux 2.4.19 ¤Ç POSIX ¤Ë¤ª¤±¤ëÃÍ
181 .\"O .SH AVAILABILITY
183 .\"O On POSIX systems on which
185 .\"O is available, both
186 .\"O .B _POSIX_MAPPED_FILES
188 .\"O .B _POSIX_SYNCHRONIZED_IO
189 .\"O are defined in \fI<unistd.h>\fP to a value greater than 0.
191 .\"O .BR sysconf (3).)
193 ¤¬»ÈÍѲÄǽ¤Ê POSIX ¥·¥¹¥Æ¥à¤Ç¤Ï
194 .B _POSIX_MAPPED_FILES
196 .B _POSIX_SYNCHRONIZED_IO
197 ¤ÎξÊý¤¬ \fI<unistd.h>\fP ¤Ç 0 ¤è¤êÂ礤¤ÃͤËÄêµÁ¤µ¤ì¤ë¡£
200 .\"O .\" POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
201 .\"O .\" -1: unavailable, 0: ask using sysconf().
202 .\"O .\" glibc defines them to 1.
203 .\" POSIX.1-2001: ¤³¤ì¤é¤ÎÃÍ¤Ï -1 ¤Þ¤¿¤Ï 0 ¤Þ¤¿¤Ï 200112L ¤ÈÄêµÁ¤µ¤ì¤ë¡£
204 .\" -1 ¤Ï»ÈÍÑÉÔ²Äǽ¡¢ 0 ¤Ï sysconf() ¤ËÌ䤤¹ç¤ï¤»¤ë
205 .\" glibc ¤Ç¤Ï 1 ¤ÈÄêµÁ¤·¤Æ¤¤¤ë¡£
210 B.O. Gallmeister, POSIX.4, O'Reilly, pp. 128-129 and 389-391.