?? mlock.html
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>mlock</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_007_678"> </a>NAME</h4><blockquote>mlock, munlock - lock or unlock a range of process address space(<b>REALTIME</b>)</blockquote><h4><a name = "tag_000_007_679"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="sysmman.h.html">sys/mman.h</a>>int mlock(const void * <i>addr</i>, size_t <i>len</i>);int munlock(const void * <i>addr</i>, size_t <i>len</i>);</code></pre></blockquote><h4><a name = "tag_000_007_680"> </a>DESCRIPTION</h4><blockquote>The function<i>mlock()</i>causes those whole pages containing any part of theaddress space of the process starting at address<i>addr</i>and continuing for<i>len</i>bytes to be memory residentuntil unlocked or until the process exits or<i>exec</i>sanother process image.The implementation may require that<i>addr</i>be a multiple of {PAGESIZE}.<p>The function<i>munlock()</i>unlocks those whole pages containing any part of theaddress spaceof the process starting at address<i>addr</i>and continuing for<i>len</i>bytes, regardless of how many times<i>mlock()</i>has been called by the processfor any of the pages in the specified range.The implementation may require that<i>addr</i>be a multiple of the {PAGESIZE}.<p>If any of the pages in the range specified to a call to<i>munlock()</i>are also mapped into the address spaces of other processes,any locks established on those pages by another processare unaffected by the call of this process to<i>munlock()</i>.If any of the pages in the range specified by a call to<i>munlock()</i>are also mapped into other portions of the address spaceof the calling process outside the range specified,any locks established on those pages via the other mappingsare also unaffected by this call.<p>Upon successful return from<i>mlock()</i>,pages in the specified range will be locked and memory resident.Upon successful return from<i>munlock()</i>,pages in the specified range will be unlocked with respect to theaddress space of the process.Memory residency of unlocked pages is unspecified.<p>The appropriate privilege is required to lock process memory with<i>mlock()</i>.</blockquote><h4><a name = "tag_000_007_681"> </a>RETURN VALUE</h4><blockquote>Upon successful completion, the<i>mlock()</i>and<i>munlock()</i>functions return a value of zero.Otherwise, no change is made to any locks in theaddress space of the process, and the function returns a value of -1 and sets<i>errno</i>to indicate the error.</blockquote><h4><a name = "tag_000_007_682"> </a>ERRORS</h4><blockquote>The <i>mlock()</i>and<i>munlock()</i>functions will fail if:<dl compact><dt>[ENOMEM]<dd>Some or all of the address range specified by the<i>addr</i>and<i>len</i>arguments does not correspond to valid mapped pages in theaddress space of the process.<dt>[ENOSYS]<dd>The implementation does not support this memory locking interface.</dl><p>The <i>mlock()</i>functions will fail if:<dl compact><dt>[EAGAIN]<dd>Some or all of the memory identified by the operation could not be lockedwhen the call was made.</dl><p>The <i>mlock()</i>and<i>munlock()</i>functions may fail if:<dl compact><dt>[EINVAL]<dd>The<i>addr</i>argument is not a multiple of {PAGESIZE}.</dl><p>The <i>mlock()</i>function may fail if:<dl compact><dt>[ENOMEM]<dd>Locking the pages mapped by the specified range wouldexceed an implementation-dependent limit on theamount of memory that the process may lock.<dt>[EPERM]<dd>The calling process does not have the appropriate privilege to perform therequested operation.</dl></blockquote><h4><a name = "tag_000_007_683"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_684"> </a>APPLICATION USAGE</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_685"> </a>SEE ALSO</h4><blockquote><i><a href="exec.html">exec</a></i>,<i><a href="_exit.html">_exit()</a></i>,<i><a href="fork.html">fork()</a></i>,<i><a href="mlockall.html">mlockall()</a></i>,<i><a href="munmap.html">munmap()</a></i>,<i><a href="sysmman.h.html"><sys/mman.h></a></i>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995)</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -