atomic_dec_and_mutex_lock(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ atomic_dec_and_mutex_lock(9) ✨

okay so this is a page from the Kernel API Manual, and the main character is atomic_dec_and_mutex_lock(9) β€” she decrements an atomic and maybe hands you a held mutex, iykyk πŸ’…


🌸 NAME 🌸

  • atomic_dec_and_mutex_lock β€” return holding mutex if we dec to 0

πŸ¦‹ SYNOPSIS πŸ¦‹

int atomic_dec_and_mutex_lock (atomic_t *cnt , struct mutex *lock );

πŸ’… ARGUMENTS πŸ’…

  • cnt β€” the atomic which we are to dec, bestie πŸŽ€
  • lock β€” the mutex to return holding if we dec to 0

πŸ”₯ DESCRIPTION πŸ”₯

the vibe is literally this: return true and hold lock if we dec to 0, return false otherwise. periodt. no cap, that’s the whole behavior ✨

lowkey important: if it returns true, you’re holding the mutex. if it returns false, you’re not. keep that energy in mind 🫢

🌈 SEE ALSO 🌈


so yeah, this iconic little page comes from the ./kernel/locking source/version situation, dated October 2026 β€” and that’s the cute sign-off, bestie πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from