Заблокировать диапазон адресного пространства процесса в физической памяти
#include <sys/mman.h>
int mlock( const void *addr,
size_t len );
- 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.
libc
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.
 | The calling process needs superuser capabilities to call mlock(). |
The successful call to mlock() function ensures that the pages are memory-resident (i.e. the addresses always reside in physical memory).
- 0
- Успешное завершение.
- -1
- Возникла ошибка. Код ошибки записан в errno.
- ENOMEM
-
- 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.
- EAGAIN
- Some or all of the memory identified by the operation couldn't be locked when the call was made.
- EPERM
- The calling process doesn't have the superuser capabilities.
POSIX 1003.1 MLR
- Точка остановки потока
- Нет
- Обработчик прерываний
- Нет
- Обработчик сигналов
- Да
- В потоке
- Да
mlockall(), mmap(), munlock(), munlockall()
Предыдущий раздел: Описание API системной библиотеки