VM_MAP_LOCK(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’– 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. returns FALSE if the lock can't be immediately acquired; otherwise returns TRUE with 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. returns FALSE if the lock can't be immediately acquired; otherwise returns TRUE with 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