Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

munlockall(2) [freebsd man page]

MLOCKALL(2)						      BSD System Calls Manual						       MLOCKALL(2)

NAME
mlockall, munlockall -- lock (unlock) the address space of a process LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/mman.h> int mlockall(int flags); int munlockall(void); DESCRIPTION
The mlockall() system call locks into memory the physical pages associated with the address space of a process until the address space is unlocked, the process exits, or execs another program image. The following flags affect the behavior of mlockall(): MCL_CURRENT Lock all pages currently mapped into the process's address space. MCL_FUTURE Lock all pages mapped into the process's address space in the future, at the time the mapping is established. Note that this may cause future mappings to fail if those mappings cause resource limits to be exceeded. Since physical memory is a potentially scarce resource, processes are limited in how much they can lock down. A single process can lock the minimum of a system-wide ``wired pages'' limit vm.max_wired and the per-process RLIMIT_MEMLOCK resource limit. If security.bsd.unprivileged_mlock is set to 0 these calls are only available to the super-user. If vm.old_mlock is set to 1 the per-process RLIMIT_MEMLOCK resource limit will not be applied for mlockall() calls. The munlockall() call unlocks any locked memory regions in the process address space. Any regions mapped after an munlockall() call will not be locked. RETURN VALUES
A return value of 0 indicates that the call succeeded and all pages in the range have either been locked or unlocked. A return value of -1 indicates an error occurred and the locked status of all pages in the range remains unchanged. In this case, the global location errno is set to indicate the error. ERRORS
mlockall() will fail if: [EINVAL] The flags argument is zero, or includes unimplemented flags. [ENOMEM] Locking the indicated range would exceed either the system or per-process limit for locked memory. [EAGAIN] Some or all of the memory mapped into the process's address space could not be locked when the call was made. [EPERM] The calling process does not have the appropriate privilege to perform the requested operation. SEE ALSO
mincore(2), mlock(2), mmap(2), munmap(2), setrlimit(2) STANDARDS
The mlockall() and munlockall() functions are believed to conform to IEEE Std 1003.1-2001 (``POSIX.1''). HISTORY
The mlockall() and munlockall() functions first appeared in FreeBSD 5.1. BUGS
The per-process resource limit is a limit on the amount of virtual memory locked, while the system-wide limit is for the number of locked physical pages. Hence a process with two distinct locked mappings of the same physical page counts as 2 pages against the per-process limit and as only a single page in the system limit. BSD
December 25, 2012 BSD

Check Out this Related Man Page

mlockall(3)						     Library Functions Manual						       mlockall(3)

NAME
mlockall, munlockall - Locks into memory, or unlocks, all of a specified process's pages (P1003.1b) LIBRARY
Realtime Library (librt.so, librt.a) SYNOPSIS
#include <sys/mman.h> int mlockall ( int flags); int munlockall (void); PARAMETERS
flags Determines whether the pages to be locked are those currently mapped by the process's address space, those that will be mapped in the future, or both. The flags argument is constructed as the OR of one or more of the constants, MCL_CURRENT or MCL_FUTURE, as defined in the <mman.h> header file. DESCRIPTION
The mlockall function causes all of the pages mapped by the process's address space to be memory resident until unlocked by a call to the munlockall function, until the process exits, or until the process calls exec. MCL_CURRENT locks all of the pages currently mapped into the process's address space. MCL_FUTURE locks all of the pages that become mapped into the process's address space in the future, when those mappings are established. You can specify MCL_CURRENT and subsequently specify MCL_FUTURE to lock both current and future address space. The munlockall function unlocks all currently mapped pages of the process's address space. Any pages that become mapped into a process's address space after a call to munlockall are not locked unless otherwise specified by a subsequent call to mlockall. Pages locked or mapped into another process's address space are unaffected by this process's call to the munlockall function. Locking the process's pages into memory also makes the process unswappable. When the pages are unlocked, the process is made swappable. A lock is not inherited across a fork. All memory locks established on an address by this process are removed if an address range associ- ated with the lock is unmapped with a call to the munmap function. You must have superuser privileges to call the mlockall function. RETURN VALUES
On a successful call to the mlockall function, a value of 0 (zero) is returned and memory is locked. On an unsuccessful call, a value of -1 is returned, no memory is locked, and errno is set to indicate that an error occurred. On a successful call to the munlockall function, a value of 0 (zero) is returned and memory is unlocked. On an unsuccessful call, a value of -1 is returned and errno is set to indicate that an error occurred. ERRORS
The mlockall and munlockall functions fail under the following condition: [ENOSYS] The implementation does not support this memory locking interface. If any of the following conditions occur, the mlockall function fails: [EAGAIN] Some or all of the memory identified by the operation could not be locked when the call was made. [EINVAL] The flags argument is zero or includes unimplemented flags. [ENOMEM] Locking all of the pages currently mapped into the process's address space exceeds an implementation-defined limit on the amount of memory that the process may lock. [EPERM] The calling process does not have the appropriate privilege to perform the requested operation. RELATED INFORMATION
Functions: exec(2), _exit(2), fork(2), munmap(2) Guide to Realtime Programming delim off mlockall(3)
Man Page