VM_MAP_LOCK(9)
π VM_MAP_LOCK β vm_map locking macros π
okay bestie, sit DOWN, because we're talking about vm_map_lock and its whole friend group β and yes, this is from the Kernel Developer's Manual, section 9, so you already know it's giving big-kid kernel energy. π§β¨
The squad is: 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. Eight little icons. All of them. Periodt. π
β¨ SYNOPSIS β¨
first things first, you gotta bring in the essentials, no skipping:
#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_map.h>
then it's just:
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);
look at that. gorgeous. no notes. π
πΈ DESCRIPTION πΈ
so here's the tea on each one, bestie, one by one:
vm_map_lock()β this macro grabs an exclusive lock on map. it's the main character lock, nobody else gets in while it's held. π«Άvm_map_unlock()β releases that exclusive lock on map. bye babe, thanks for coming. πvm_map_lock_read()β this one gets a read-lock on map. like, you can look, but don't touch. πvm_map_unlock_read()β releases the read-lock on map. lookin' time is over. πvm_map_trylock()β tries to snag an exclusive lock on map, but it's not gonna wait around for it. if the lock can't be acquired immediately it returnsFALSE; otherwise it returnsTRUEwith the lock acquired. lowkey impatient, highkey efficient. πvm_map_trylock_read()β same vibe but for a read-lock on map. returnsFALSEif the lock can't be acquired immediately; otherwise returnsTRUEwith the lock acquired. no waiting, no begging. β¨vm_map_lock_upgrade()β attempts to atomically upgrade a read-lock on map to an exclusive lock. glow-up but make it atomic. π¦vm_map_lock_downgrade()β attempts to downgrade an exclusive lock on map to a read-lock. sometimes you just gotta step back and let the read-locks breathe. π
π οΈ IMPLEMENTATION NOTES π οΈ
as of right now, bestie, all of these locking macros implement their locks as sleep locks. every single one. that's the whole note. fr fr. π
π SEE ALSO π
vm_map(9)β go read it, it's the source material, iykyk. π
π AUTHORS π
this manual page was written by Bruce M Simpson <bms@spc.org>. king behavior, honestly. π«‘
aaaand that's the whole page, bestie!! this one came from Debian, dated July 19, 2003 β vintage but still slaying. go lock your maps responsibly, mwah ππβ¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2003 Bruce M Simpson <bms@spc.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms