Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mlockall(2) [netbsd 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 and the per-process RLIMIT_MEMLOCK resource limit. 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 conform to IEEE Std 1003.1b-1993 (``POSIX.1''). HISTORY
The mlockall() and munlockall() functions first appeared in NetBSD 1.5. 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
June 12, 1999 BSD

Check Out this Related Man Page

MLOCKALL(P)						     POSIX Programmer's Manual						       MLOCKALL(P)

NAME
mlockall, munlockall - lock/unlock the address space of a process (REALTIME) SYNOPSIS
#include <sys/mman.h> int mlockall(int flags); int munlockall(void); DESCRIPTION
The mlockall() function shall cause all of the pages mapped by the address space of a process to be memory-resident until unlocked or until the process exits or execs another process image. The flags argument determines whether the pages to be locked are those currently mapped by the address space of the process, those that are mapped in the future, or both. The flags argument is constructed from the bitwise- inclusive OR of one or more of the following symbolic constants, defined in <sys/mman.h>: MCL_CURRENT Lock all of the pages currently mapped into the address space of the process. MCL_FUTURE Lock all of the pages that become mapped into the address space of the process in the future, when those mappings are established. If MCL_FUTURE is specified, and the automatic locking of future mappings eventually causes the amount of locked memory to exceed the amount of available physical memory or any other implementation-defined limit, the behavior is implementation-defined. The manner in which the implementation informs the application of these situations is also implementation-defined. The munlockall() function shall unlock all currently mapped pages of the address space of the process. Any pages that become mapped into the address space of the process after a call to munlockall() shall not be locked, unless there is an intervening call to mlockall() speci- fying MCL_FUTURE or a subsequent call to mlockall() specifying MCL_CURRENT. If pages mapped into the address space of the process are also mapped into the address spaces of other processes and are locked by those processes, the locks established by the other processes shall be unaffected by a call by this process to munlockall(). Upon successful return from the mlockall() function that specifies MCL_CURRENT, all currently mapped pages of the process' address space shall be memory-resident and locked. Upon return from the munlockall() function, all currently mapped pages of the process' address space shall be unlocked with respect to the process' address space. The memory residency of unlocked pages is unspecified. The appropriate privilege is required to lock process memory with mlockall(). RETURN VALUE
Upon successful completion, the mlockall() function shall return a value of zero. Otherwise, no additional memory shall be locked, and the function shall return a value of -1 and set errno to indicate the error. The effect of failure of mlockall() on previously existing locks in the address space is unspecified. If it is supported by the implementation, the munlockall() function shall always return a value of zero. Otherwise, the function shall return a value of -1 and set errno to indicate the error. ERRORS
The mlockall() function shall fail if: 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. The mlockall() function may fail if: ENOMEM Locking all of the pages currently mapped into the address space of the process would exceed 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. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
None. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
exec() , exit() , fork() , mlock() , munmap() , the Base Definitions volume of IEEE Std 1003.1-2001, <sys/mman.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 MLOCKALL(P)
Man Page