The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 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 function mlockall() causes 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 will be mapped in the future, or both. The flags argument is constructed from the 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-dependent limit, the behaviour is implementation-dependent. The manner in which the implementation informs the application of these situations is also implementation-dependent.

The munlockall() function 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 munlockall() will not be locked, unless there is an intervening call to mlockall() specifying MCL_FUTURE or a subsequent call to mlockall() 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 by this process to munlockall().

Upon successful return from the mlockall() function that specifies MCL_CURRENT, all currently mapped pages of the process's address space will be memory resident and locked. Upon return from the munlockall() function, all currently mapped pages of the process's address space will be unlocked with respect to the process's 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 returns a value of zero. Otherwise, no additional memory is locked, and the function returns a value of -1 and sets 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 always returns a value of zero. Otherwise, the function returns a value of -1 and sets errno to indicate the error.

 ERRORS

The mlockall() and munlockall() functions will fail if:
[ENOSYS]
The implementation does not support this memory locking interface.

The mlockall() function will 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-dependent 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.

 EXAMPLES

None.

 APPLICATION USAGE

None.

 SEE ALSO

exec, _exit(), fork(), mlock(), munmap(), <sys/mman.h>.

DERIVATION

Derived from the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995)

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]