mlockall(), munlockall()

lock/unlock the address space of a process 

Realtime Function


SYNOPSIS

#include <sys/mman.h>

int mlockall(int flags);

int munlockall(void);


DESCRIPTION

The mlockall() function cause 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 are mapped in the future, or both. The flags argument is constructed from the bitwise-inclusive OR of one or more of the following symbolic constants, defined in <sys/mman.h>:

MCL_CURRENT 

Locks all pages currently mapped into the address space of the process.

MCL_FUTURE 

Locks all pages that become mapped into the address space of the process in the future, when those mappings are established.

The appropriate privilege is required to lock process memory with mlockall().

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() are not locked, unless there is an intervening call to mlockall() specifying MCL_FUTURE or a subsequent call to mlockall() 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 the munlockall() call.


PARAMETERS

flags 

Specifies the flags that determine whether the pages to be locked are those currently mapped, those that are mapped in the future, or both.


RETURN VALUES

The munlockall() function always returns 0.

On success, the mlockall() function returns 0. On failure, the mlockall() function returns -1, locks no additional memory, and sets errno to one of the following:

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.

ENOMEM 

Locking all of the pages currently mapped into the address space of the process would exceed the amount of memory that the process may lock.

EPERM 

The calling process does not have the appropriate privilege to perform the requested operation.


CONFORMANCE

UNIX 03.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

On the NuTCRACKER Platform the mlockall() function requires the calling process to have the SE_INC_BASE_PRIORITY_NAME privilege.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
exec(), exit(), fork(), mlock(), munmap()


PTC MKS Toolkit 10.3 Documentation Build 39.