mlockall

基本介紹

  • 外文名:mlockall
  • 頭檔案:#include <sys/mman.h>
  • 原型:int mlockall(int flags);
  • 返回值:成功:返回0;錯誤:返回-1
頭檔案,原型,參數,返回值,功能,頭檔案中的解釋,相關函式,

頭檔案

#include <sys/mman.h>

原型

int mlockall(int flags);

參數

flags可以是下面宏的按位或:
MCL_CURRENT ——Lock all pages which are currently mapped into the address space of the process.
MCL_FUTURE ——— Lock all pages which will become mapped into the address space of the process in the future. These could be for instance new pages required by a growing heap and stack as well as new memory mapped files or shared memory regions.

返回值

成功:返回0;
錯誤:返回-1,errno被設定。

功能

將進程使用的部分或者全部的地址空間鎖定在物理記憶體中,防止其被交換到swap空間。
有些對時間敏感的套用會希望全部使用物理記憶體,以提高數據訪問和操作的效率。

頭檔案中的解釋

mlock() and mlockall() respectively lock part or all of the calling
process's virtual address space into RAM, preventing that memory from
being paged to the swap area. munlock() and munlockall() perform the
converse operation, respectively unlocking part or all of the calling
process's virtual address space, so that pages in the specified virtual
address range may once more to be swapped out if required by the kernel
memory manager. Memory locking and unlocking are performed in units of
whole pages.

相關函式

int mlock(const void *addr, size_t len);
int munlock(const void *addr, size_t len);
int munlockall(void);

相關詞條

熱門詞條

聯絡我們