📄 posix_madvise.html
字号:
<!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-2003 The Open Group, All Rights Reserved --><title>posix_madvise</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="posix_madvise"></a> <a name="tag_03_423"></a><!-- posix_madvise --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_423_01"></a>NAME</h4><blockquote>posix_madvise - memory advisory information and alignment control (<b>ADVANCED REALTIME</b>)</blockquote><h4><a name="tag_03_423_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('ADV')">ADV</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 posix_madvise(void *</tt><i>addr</i><tt>, size_t</tt> <i>len</i><tt>, int</tt> <i>advice</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_423_03"></a>DESCRIPTION</h4><blockquote><p><sup>[<a href="javascript:open_code('MF')">MF|SHM</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The <i>posix_madvise</i>() function need only be supported if either the Memory Mapped Files or the Shared Memory Objects optionsare supported. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>The <i>posix_madvise</i>() function shall advise the implementation on the expected behavior of the application with respect tothe data in the memory starting at address <i>addr</i>, and continuing for <i>len</i> bytes. The implementation may use thisinformation to optimize handling of the specified data. The <i>posix_madvise</i>() function shall have no effect on the semanticsof access to memory in the specified range, although it may affect the performance of access.</p><p>The implementation may require that <i>addr</i> be a multiple of the page size, which is the value returned by <a href="../functions/sysconf.html"><i>sysconf</i>()</a> when the name value _SC_PAGESIZE is used.</p><p>The advice to be applied to the memory range is specified by the <i>advice</i> parameter and may be one of the followingvalues:</p><dl compact><dt>POSIX_MADV_NORMAL</dt><dd><br>Specifies that the application has no advice to give on its behavior with respect to the specified range. It is the defaultcharacteristic if no advice is given for a range of memory.</dd><dt>POSIX_MADV_SEQUENTIAL</dt><dd><br>Specifies that the application expects to access the specified range sequentially from lower addresses to higher addresses.</dd><dt>POSIX_MADV_RANDOM</dt><dd><br>Specifies that the application expects to access the specified range in a random order.</dd><dt>POSIX_MADV_WILLNEED</dt><dd><br>Specifies that the application expects to access the specified range in the near future.</dd><dt>POSIX_MADV_DONTNEED</dt><dd><br>Specifies that the application expects that it will not access the specified range in the near future.</dd></dl><p>These values are defined in the <a href="../basedefs/sys/mman.h.html"><i><sys/mman.h></i></a> header.</p></blockquote><h4><a name="tag_03_423_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, <i>posix_madvise</i>() shall return zero; otherwise, an error number shall be returned to indicatethe error.</p></blockquote><h4><a name="tag_03_423_05"></a>ERRORS</h4><blockquote><p>The <i>posix_madvise</i>() function shall fail if:</p><dl compact><dt>[EINVAL]</dt><dd>The value of <i>advice</i> is invalid.</dd><dt>[ENOMEM]</dt><dd>Addresses in the range starting at <i>addr</i> and continuing for <i>len</i> bytes are partly or completely outside the rangeallowed for the address space of the calling process.</dd></dl><p>The <i>posix_madvise</i>() function may fail if:</p><dl compact><dt>[EINVAL]</dt><dd>The value of <i>addr</i> is not a multiple of the value returned by <a href="../functions/sysconf.html"><i>sysconf</i>()</a>when the name value _SC_PAGESIZE is used.</dd><dt>[EINVAL]</dt><dd>The value of <i>len</i> is zero.</dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_423_06"></a>EXAMPLES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_423_07"></a>APPLICATION USAGE</h4><blockquote><p>The <i>posix_madvise</i>() function is part of the Advisory Information option and need not be provided on allimplementations.</p></blockquote><h4><a name="tag_03_423_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_423_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_423_10"></a>SEE ALSO</h4><blockquote><p><a href="mmap.html"><i>mmap</i>()</a> , <a href="posix_fadvise.html"><i>posix_fadvise</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_423_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 6. Derived from IEEE Std 1003.1d-1999.</p><p>IEEE PASC Interpretation 1003.1 #102 is applied.</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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -