add directory Ref-docs
This commit is contained in:
258
Ref-docs/POSIX/susv3/functions/msync.html
Normal file
258
Ref-docs/POSIX/susv3/functions/msync.html
Normal file
@@ -0,0 +1,258 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
||||
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
||||
<title>msync</title>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
||||
</script>
|
||||
|
||||
<basefont size="3"> <a name="msync"></a> <a name="tag_03_397"></a><!-- msync -->
|
||||
<!--header start-->
|
||||
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
||||
IEEE Std 1003.1-2001<br>
|
||||
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
||||
|
||||
<!--header end-->
|
||||
<hr size="2" noshade>
|
||||
<h4><a name="tag_03_397_01"></a>NAME</h4>
|
||||
|
||||
<blockquote>msync - synchronize memory with physical storage</blockquote>
|
||||
|
||||
<h4><a name="tag_03_397_02"></a>SYNOPSIS</h4>
|
||||
|
||||
<blockquote class="synopsis">
|
||||
<div class="box"><code><tt><sup>[<a href="javascript:open_code('MF SIO')">MF SIO</a>]</sup> <img src="../images/opt-start.gif" alt=
|
||||
"[Option Start]" border="0"> #include <<a href="../basedefs/sys/mman.h.html">sys/mman.h</a>><br>
|
||||
<br>
|
||||
int msync(void *</tt><i>addr</i><tt>, size_t</tt> <i>len</i><tt>, int</tt> <i>flags</i><tt>); <img src="../images/opt-end.gif"
|
||||
alt="[Option End]" border="0"></tt></code></div>
|
||||
|
||||
<tt><br>
|
||||
</tt></blockquote>
|
||||
|
||||
<h4><a name="tag_03_397_03"></a>DESCRIPTION</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>The <i>msync</i>() function shall write all modified data to permanent storage locations, if any, in those whole pages
|
||||
containing any part of the address space of the process starting at address <i>addr</i> and continuing for <i>len</i> bytes. If no
|
||||
such storage exists, <i>msync</i>() need not have any effect. If requested, the <i>msync</i>() function shall then invalidate
|
||||
cached copies of data.</p>
|
||||
|
||||
<p>The implementation shall require that <i>addr</i> be a multiple of the page size as returned by <a href=
|
||||
"../functions/sysconf.html"><i>sysconf</i>()</a>.</p>
|
||||
|
||||
<p>For mappings to files, the <i>msync</i>() function shall ensure that all write operations are completed as defined for
|
||||
synchronized I/O data integrity completion. It is unspecified whether the implementation also writes out other file attributes.
|
||||
When the <i>msync</i>() function is called on MAP_PRIVATE mappings, any modified data shall not be written to the underlying object
|
||||
and shall not cause such data to be made visible to other processes. It is unspecified whether data in MAP_PRIVATE mappings has any
|
||||
permanent storage locations. <sup>[<a href="javascript:open_code('SHM')">SHM|TYM</a>]</sup> <img src="../images/opt-start.gif" alt=
|
||||
"[Option Start]" border="0"> The effect of <i>msync</i>() on a shared memory object or a typed memory object is unspecified.
|
||||
<img src="../images/opt-end.gif" alt="[Option End]" border="0"> The behavior of this function is unspecified if the mapping was not
|
||||
established by a call to <a href="../functions/mmap.html"><i>mmap</i>()</a>.</p>
|
||||
|
||||
<p>The <i>flags</i> argument is constructed from the bitwise-inclusive OR of one or more of the following flags defined in the <a
|
||||
href="../basedefs/sys/mman.h.html"><i><sys/mman.h></i></a> header:</p>
|
||||
|
||||
<center>
|
||||
<table border="1" cellpadding="3" align="center">
|
||||
<tr valign="top">
|
||||
<th align="center">
|
||||
<p class="tent"><b>Symbolic Constant</b></p>
|
||||
</th>
|
||||
<th align="center">
|
||||
<p class="tent"><b>Description</b></p>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="left">
|
||||
<p class="tent">MS_ASYNC</p>
|
||||
</td>
|
||||
<td align="left">
|
||||
<p class="tent">Perform asynchronous writes.</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="left">
|
||||
<p class="tent">MS_SYNC</p>
|
||||
</td>
|
||||
<td align="left">
|
||||
<p class="tent">Perform synchronous writes.</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="left">
|
||||
<p class="tent">MS_INVALIDATE</p>
|
||||
</td>
|
||||
<td align="left">
|
||||
<p class="tent">Invalidate cached data.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
<p>When MS_ASYNC is specified, <i>msync</i>() shall return immediately once all the write operations are initiated or queued for
|
||||
servicing; when MS_SYNC is specified, <i>msync</i>() shall not return until all write operations are completed as defined for
|
||||
synchronized I/O data integrity completion. Either MS_ASYNC or MS_SYNC is specified, but not both.</p>
|
||||
|
||||
<p>When MS_INVALIDATE is specified, <i>msync</i>() shall invalidate all cached copies of mapped data that are inconsistent with the
|
||||
permanent storage locations such that subsequent references shall obtain data that was consistent with the permanent storage
|
||||
locations sometime between the call to <i>msync</i>() and the first subsequent memory reference to the data.</p>
|
||||
|
||||
<p>If <i>msync</i>() causes any write to a file, the file's <i>st_ctime</i> and <i>st_mtime</i> fields shall be marked for
|
||||
update.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_397_04"></a>RETURN VALUE</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>Upon successful completion, <i>msync</i>() shall return 0; otherwise, it shall return -1 and set <i>errno</i> to indicate the
|
||||
error.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_397_05"></a>ERRORS</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>The <i>msync</i>() function shall fail if:</p>
|
||||
|
||||
<dl compact>
|
||||
<dt>[EBUSY]</dt>
|
||||
|
||||
<dd>Some or all of the addresses in the range starting at <i>addr</i> and continuing for <i>len</i> bytes are locked, and
|
||||
MS_INVALIDATE is specified.</dd>
|
||||
|
||||
<dt>[EINVAL]</dt>
|
||||
|
||||
<dd>The value of <i>flags</i> is invalid.</dd>
|
||||
|
||||
<dt>[EINVAL]</dt>
|
||||
|
||||
<dd>The value of <i>addr</i> is not a multiple of the page size {PAGESIZE}.</dd>
|
||||
|
||||
<dt>[ENOMEM]</dt>
|
||||
|
||||
<dd>The addresses in the range starting at <i>addr</i> and continuing for <i>len</i> bytes are outside the range allowed for the
|
||||
address space of a process or specify one or more pages that are not mapped.</dd>
|
||||
</dl>
|
||||
</blockquote>
|
||||
|
||||
<hr>
|
||||
<div class="box"><em>The following sections are informative.</em></div>
|
||||
|
||||
<h4><a name="tag_03_397_06"></a>EXAMPLES</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>None.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_397_07"></a>APPLICATION USAGE</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>The <i>msync</i>() function is only supported if the Memory Mapped Files option and the Synchronized Input and Output option are
|
||||
supported, and thus need not be available on all implementations.</p>
|
||||
|
||||
<p>The <i>msync</i>() function should be used by programs that require a memory object to be in a known state; for example, in
|
||||
building transaction facilities.</p>
|
||||
|
||||
<p>Normal system activity can cause pages to be written to disk. Therefore, there are no guarantees that <i>msync</i>() is the only
|
||||
control over when pages are or are not written to disk.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_397_08"></a>RATIONALE</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>The <i>msync</i>() function writes out data in a mapped region to the permanent storage for the underlying object. The call to
|
||||
<i>msync</i>() ensures data integrity of the file.</p>
|
||||
|
||||
<p>After the data is written out, any cached data may be invalidated if the MS_INVALIDATE flag was specified. This is useful on
|
||||
systems that do not support read/write consistency.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_397_09"></a>FUTURE DIRECTIONS</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>None.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_397_10"></a>SEE ALSO</h4>
|
||||
|
||||
<blockquote>
|
||||
<p><a href="mmap.html"><i>mmap</i>()</a> , <a href="sysconf.html"><i>sysconf</i>()</a> , the Base Definitions volume of
|
||||
IEEE Std 1003.1-2001, <a href="../basedefs/sys/mman.h.html"><i><sys/mman.h></i></a></p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_397_11"></a>CHANGE HISTORY</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>First released in Issue 4, Version 2.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_397_12"></a>Issue 5</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>Moved from X/OPEN UNIX extension to BASE.</p>
|
||||
|
||||
<p>Aligned with <i>msync</i>() in the POSIX Realtime Extension as follows:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>The DESCRIPTION is extensively reworded.</p>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<p>[EBUSY] and a new form of [EINVAL] are added as mandatory error conditions.</p>
|
||||
</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_397_13"></a>Issue 6</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>The <i>msync</i>() function is marked as part of the Memory Mapped Files and Synchronized Input and Output options.</p>
|
||||
|
||||
<p>The following changes are made for alignment with the ISO POSIX-1:1996 standard:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>The [EBUSY] mandatory error condition is added.</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>The DESCRIPTION is updated to state that implementations require <i>addr</i> to be a multiple of the page size.</p>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<p>The second [EINVAL] error condition is made mandatory.</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>The DESCRIPTION is updated for alignment with IEEE Std 1003.1j-2000 by adding reference to typed memory objects.</p>
|
||||
</blockquote>
|
||||
|
||||
<div class="box"><em>End of informative text.</em></div>
|
||||
|
||||
<hr>
|
||||
<hr size="2" noshade>
|
||||
<center><font size="2"><!--footer start-->
|
||||
UNIX ® is a registered Trademark of The Open Group.<br>
|
||||
POSIX ® is a registered Trademark of The IEEE.<br>
|
||||
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
||||
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
||||
]</font></center>
|
||||
|
||||
<!--footer end-->
|
||||
<hr size="2" noshade>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user