#include <sys/mman.h>
int mlockall(int flags);
int munlockall(void);
MT-Safe
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.