BUF_ISLOCKED(9)

πŸ’– BUF_ISLOCKED πŸ’–

okay bestie, so you wanna know if a buffer's lock is held?? say less, this page has you covered 🫢 it's from the Kernel Developer's Manual (section 9, kernel-land only, no user-space shenanigans here) and it's literally just one tiny function that tells you what's up with a lock. no cap.


✨ SYNOPSIS ✨

like always, you gotta include the whole squad first or nothing works:

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/uio.h>
#include <sys/bio.h>
#include <sys/buf.h>

int
BUF_ISLOCKED(struct buf *bp);

🌸 DESCRIPTION 🌸

so BUF_ISLOCKED() returns the status of the lock linked to the buffer, and it does it in relation to curthread (that's the thread you're running as, iykyk). it's giving "who's holding this lock and is it me??" energy πŸ’…

it can return:

  • LK_EXCLUSIVE β€” an exclusive lock is held by curthread. that's you bestie, main character energy πŸ‘‘
  • LK_EXCLOTHER β€” an exclusive lock is held by someone other than curthread. not you, someone else is in there πŸ™ˆ
  • LK_SHARED β€” a shared lock is held. everybody's sharing, cute πŸŽ€
  • 0 β€” the lock is not held by anyone. fully free, unlocked, living its best life ✨

πŸ”₯ SEE ALSO πŸ”₯

buf(9), BUF_LOCK(9), BUF_UNLOCK(9), lockmgr(9), lockstatus(9)


πŸ’œ AUTHORS πŸ’œ

this manual page was written by Attilio Rao <attilio@FreeBSD.org>. iconic behavior fr fr 🌈


Debian Β· January 22, 2008 Β· that's the Debian-flavored BUF_ISLOCKED(9) page, mwah πŸ’‹ go check your locks bestie, ily, bye!! πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from