mlock()

QNX SDP8.0C Library ReferenceAPIDeveloper

Lock a range of process address space in physical memory

Synopsis:

#include <sys/mman.h>

int mlock(const void * addr, 
          size_t len);

Arguments:

addr
The starting address for the range of process address space.
len
The amount of the memory to lock, in bytes. There's no limit on the amount of memory that a process may lock, other than the amount of physical memory in the system.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

Note:
In this QNX OS release, all memory is locked for the entire duration of the process, so this function does nothing other than checking that the provided range is fully mapped and backed (see below).

The mlock() function causes the whole pages containing any part of the calling process's address space starting at address addr and continuing for len bytes to be memory-resident until unlocked or until the process exits or is replaced by an exec*() call.

Memory-resident is a term used to indicate that the addresses always reside in physical memory. For more information, see Memory management in the Process Manager chapter of the System Architecture guide.

Returns:

0 on success, -1 on failure (errno is set).

Errors:

ENOMEM
The provided range is not fully mapped and backed.

Classification:

POSIX 1003.1 MLR

Safety:
Cancellation pointNo
Signal handlerYes
ThreadYes
Page updated: