MLOCKALL(3)

NAME
mlockall, munlockall - lock (or unlock) address space

SYNOPSIS

#include <sys/mman.h>

int mlockall(flags)
int flags;

int munlockall()

DESCRIPTION

mlockall() locks all pages mapped by an address space in memory. The value of flags determines whether the pages to be locked are simply those currently mapped by the address space, those that will be mapped in the future, or both. flags is built from the options defined in <sys/mman.h> as:

    #define MCL_CURRENT	0x1	/* lock current mappings */
    #define MCL_FUTURE	0x2	/* lock future mappings */

If MCL_FUTURE is specified to mlockall() , then as mappings are added to the address space (or existing mappings are replaced) they will also be locked, provided sufficient memory is available.

Mappings locked via mlockall() with any option may be explicitly unlocked with a munlock() call.

munlockall() removes address space locks and locks on mappings in the address space.

All conditions and constraints on the use of locked memory as exist for mlock() apply to mlockall() .

RETURN VALUES

mlockall() and munlockall() return:

0   on success.

-1  on failure and set errno to indicate the error.

ERRORS

EAGAIN
    (mlockall() only.) Some or all of the memory in the address space could not be locked due to sufficient resources.

EINVAL
    flags contains values other than MCL_CURRENT and MCL_FUTURE.

EPERM
    The process's effective user ID is not super-user.

SEE ALSO
mctl(2), mlock(3), mmap(2)