Files
oldlinux-files/Ref-docs/POSIX/susv3/functions/posix_madvise.html
2024-02-19 00:21:47 -05:00

184 lines
6.3 KiB
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 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-2001<br>
Copyright &copy; 2001 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 &lt;<a href="../basedefs/sys/mman.h.html">sys/mman.h</a>&gt;<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 options
are 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 to
the data in the memory starting at address <i>addr</i>, and continuing for <i>len</i> bytes. The implementation may use this
information to optimize handling of the specified data. The <i>posix_madvise</i>() function shall have no effect on the semantics
of 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 following
values:</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 default
characteristic 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>&lt;sys/mman.h&gt;</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 indicate
the 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 range
allowed 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 all
implementations.</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&nbsp;Std&nbsp;1003.1-2001, <a href=
"../basedefs/sys/mman.h.html"><i>&lt;sys/mman.h&gt;</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&nbsp;Std&nbsp;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 &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; 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>