VM_MAP_LOCK(9)
π VM_MAP_LOCK β the it-girl manual page (section 9, kernel devs only bestie) π
okay so. this is VM_MAP_LOCK(9), from the Kernel Developer's Manual, and it's literally the group chat of vm_map locking macros. like, all the little lock/unlock besties in one place. let's get into it β¨
πΈ NAME πΈ
vm_map_lock, vm_map_unlock, vm_map_lock_read, vm_map_unlock_read, vm_map_trylock, vm_map_trylock_read, vm_map_lock_upgrade, vm_map_lock_downgrade β the vm_map locking macros, aka the whole friend group π«Ά
π SYNOPSIS π
like, include these first or nothing works, iykyk:
#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_map.h>
and here's the cast of characters π
void
vm_map_lock(vm_map_t map);
void
vm_map_unlock(vm_map_t map);
void
vm_map_lock_read(vm_map_t map);
void
vm_map_unlock_read(vm_map_t map);
int
vm_map_trylock(vm_map_t map);
int
vm_map_trylock_read(vm_map_t map);
int
vm_map_lock_upgrade(vm_map_t map);
int
vm_map_lock_downgrade(vm_map_t map);
β¨ DESCRIPTION β¨
literally the whole vibe, one macro at a time:
vm_map_lock()β gets an exclusive lock on map. it's giving main character energy, nobody else gets in πvm_map_unlock()β releases that exclusive lock on map. bye bestie πvm_map_lock_read()β gets a read-lock on map. you can look, just don't touch π¦vm_map_unlock_read()β releases the read-lock on map. slay, we're done reading πΈvm_map_trylock()β attempts to get an exclusive lock on map, but like, no waiting around. returnsFALSEif the lock can't be immediately acquired; otherwise returnsTRUEwith the lock acquired. it's giving "if you're free, cool, if not i'm out" πvm_map_trylock_read()β same energy but for a read-lock on map. returnsFALSEif the lock can't be immediately acquired; otherwise returnsTRUEwith the lock acquired π₯vm_map_lock_upgrade()β attempts to atomically upgrade a read-lock on map to an exclusive lock. glow-up, but for locks β¨vm_map_lock_downgrade()β attempts to downgrade an exclusive lock on map to a read-lock. not every era needs to be the loud one, and that's okay π
π§ IMPLEMENTATION NOTES π§
ngl, right now all of these locking macros implement their locks as sleep locks</> β that's the current tea, fr fr β
π SEE ALSO π
vm_map(9)β go read it, it's the source of truth bestie π«Ά
π AUTHORS π
This manual page was written by Bruce M Simpson <bms@spc.org>. iconic of him, we stan π
okay that's the whole page, no cap. every macro documented, nothing skipped, vibe check passed β
sign-off: Debian, dated July 19, 2003 β so this page is vintage, and honestly? vintage is trending again ππ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2003 Bruce M Simpson <bms@spc.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms