Locks or unlocks the address space of a process.
Standard C Library (libc.a)
#include <sys/mman.h>
int mlockall (flags)
int flags;
int munlockall (void);
When MCL_FUTURE is specified, the future mapping functions might fail if the system is not able to lock this amount of memory because of lack of resources, for example.
The munlockall subroutine unlocks 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 the munlockall subroutine are not locked, unless there is an intervening call to the mlockall subroutine specifying MCL_FUTURE or a subsequent call to the mlockall subroutine 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 are unaffected by a call to the munlockall subroutine.
Upon successful return from a mlockall subroutine that specifies MCL_CURRENT, all currently mapped pages of the process' address space are memory-resident and locked. Upon return from the munlockall subroutine, all currently mapped pages of the process' address space are unlocked with respect to the process' address space.
The calling process must have the root user authority to use this subroutine.
Item | Description |
---|---|
flags | 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. |
Upon successful completion, the mlockall subroutine returns 0. Otherwise, no additional memory is locked, and the subroutine returns -1 and sets errno to indicate the error.
Upon successful completion, the munlockall subroutine returns 0. Otherwise, no additional memory is unlocked, and the subroutine returns -1 and sets errno to indicate the error.
Item | Description |
---|---|
EINVAL | The flags parameter is 0, or includes unimplemented flags or the process has already some plocked memory. |
ENOMEM | Locking all of the pages currently mapped into the address space of the process would exceed the limit on the amount of memory that the process may lock. |
EPERM | The calling process does not have the appropriate authority to perform the requested operation. |
The munlockall subroutine fails if:
Item | Description |
---|---|
EINVAL | The process has already some plocked memory |
EPERM | The calling process does not have the appropriate privilege to perform the requested operation |