VSLOCK(9)
okay bestie, welcome to VSLOCK(9) β straight out of the Kernel Developer's Manual β¨ this one is short but it's literally about locking user space addresses in memory, so let's go π
π NAME π
vslock, vsunlock β lock/unlock user space addresses in memory π
β¨ SYNOPSIS β¨
first, grab the include squad π«Ά:
#include <sys/param.h>
#include <sys/proc.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
then the function signatures, exactly as they are:
int
vslock(void *addr, size_t len);
void
vsunlock(void *addr, size_t len);
π¦ DESCRIPTION π¦
so like, vslock() and vsunlock() are the lock/unlock duo. vslock() locks a range of addresses belonging to the currently running process into memory, and vsunlock() unlocks that range. no cap. π
the actual amount of memory locked is a multiple of the machine's page size β that's the vibe. the starting page number is computed by truncating addr to the nearest preceding page boundary, and by rounding up addr + len to the next page boundary. boundaries are lowkey main character energy. π«Ά
the process context to use for this operation is taken from the global variable curproc. that's the whole context situation, periodt. π«
π« RETURN VALUES π«
vslock() returns 0 on success. otherwise it returns one of the errors listed below. π
π₯ ERRORS π₯
vslock() will fail if:
[EINVAL]β theaddrandlenparameters specify a memory range that wraps around the end of the machine address space. π[ENOMEM]β the size of the specified address range exceeds the system limit on locked memory. π[EFAULT]β some portion of the indicated address range is not allocated. there was an error faulting/mapping a page. π«
that's the whole page, bestie. this one came from Debian, dated August 29, 2012. now go forth and lock those addresses responsibly π β¨π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 1996 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms