[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    mlockall(3C) manual page Table of Contents

Name

mlockall, munlockall - lock or unlock address space

Synopsis

#include <sys/mman.h>

int mlockall(int flags);

int munlockall(void);

MT-Level

MT-Safe

Description

The function mlockall() causes all pages mapped by an address space to be locked in memory.

The value of flags determines whether the pages to be locked are those currently mapped by the address space, those that will be mapped in the future, or both:


    MCL_CURRENT    Lock current mappings
    MCL_FUTURE    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.

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

Locks established with mlockall() are not inherited by a child process after a fork() and are not nested.

Return Values

Upon successful completion, the functions mlockall() and munlockall() return 0; otherwise, they return -1 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

fork(2) , memcntl(2) , mmap(2) , plock(3C) , mlock(3C) , sysconf(3C)

Notes

mlockall() and munlockall() require super-user privileges.


Table of Contents