atomic_dec_and_mutex_lock(9)
β¨ 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 returnstrue, youβre holding the mutex. if it returnsfalse, youβre not. keep that energy in mind π«Ά
π SEE ALSO π
- Kernel file:
./kernel/locking/mutex.c mutex_lock(9)mutex_unlock(9)ww_mutex_unlock(9)ww_mutex_trylock(9)mutex_lock_interruptible(9)mutex_lock_killable(9)mutex_lock_io(9)mutex_trylock(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms