Lock a range of process address space in physical memory
#include <sys/mman.h> int mlock(const void * addr, size_t len);
- The starting address for the range of process address space.
- 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.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The mlock() function locks a range of process address space starting at address addr and continuing for length len. The addr must be a multiple of PAGESIZE, which depends on the target platform.
In order to lock memory, your process must have the PROCMGR_AID_MEM_LOCK ability enabled. For more information, see procmgr_ability() .
The successful call to mlock() function ensures that the pages are memory-resident (i.e. the addresses always reside in physical memory). For more information, see " Locking memory " in the Process Manager chapter of the System Architecture guide.
- An error occurred ( errno is set).
- Some or all of the address range specified by the addr and len arguments doesn't correspond to valid mapped pages in the address space of the process.
- Locking the pages mapped by the specified range would exceed an implementation-defined limit on the amount of memory that the process may lock. This implementation-defined limit is set by RLIMIT_MEMLOCK rlimit.
- Some or all of the memory identified by the operation couldn't be locked when the call was made.
- The calling process doesn't have the required permission; see procmgr_ability() .
Last modified: 2013-12-23