|
NAMEmlock , munlock —
lock (unlock) physical pages in memory
LIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <sys/mman.h>
int
int
DESCRIPTIONThemlock () system call locks into memory the physical
pages associated with the virtual address range starting at
addr for len bytes. The
munlock () system call unlocks pages previously locked
by one or more mlock () calls. For both, the
addr argument should be aligned to a multiple of the
page size. If the len argument is not a multiple of the
page size, it will be rounded up to be so. The entire range must be allocated.
After an Since physical memory is a potentially scarce resource, processes
are limited in how much they can lock down. The amount of memory that a
single process can If security.bsd.unprivileged_mlock is set to 0 these calls are only available to the super-user. RETURN VALUESUpon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the error.If the call succeeds, all pages in the range become locked (unlocked); otherwise the locked status of all pages in the range remains unchanged. ERRORSThemlock () system call will fail if:
munlock () system call will fail if:
SEE ALSOfork(2), mincore(2), minherit(2), mlockall(2), mmap(2), munlockall(2), munmap(2), setrlimit(2), getpagesize(3)HISTORYThemlock () and munlock () system
calls first appeared in 4.4BSD.
BUGSAllocating too much wired memory can lead to a memory-allocation deadlock which requires a reboot to recover from.The per-process and system-wide resource limits of locked memory apply to the amount of virtual memory locked, not the amount of locked physical pages. Hence two distinct locked mappings of the same physical page counts as 2 pages aginst the system limit, and also against the per-process limit if both mappings belong to the same physical map. The per-process resource limit is not currently supported.
Visit the GSP FreeBSD Man Page Interface. |