test_and_set_bit_lock(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… test_and_set_bit_lock(9) πŸ’…

okay so welcome to the Kernel API Manual corner, bestie β€” this page is literally about test_and_set_bit_lock, and it's giving tiny atomic bit-lock icon energy. ✨

🌸 NAME 🌸

test_and_set_bit_lock β€” sets a bit, returns its old value, and it's for lock. That's the whole vibe: set the bit, hand back what was there before, lock-style. Periodt. πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

bool test_and_set_bit_lock (long nr , volatile unsigned long *addr );

Lowkey just keep that signature exactly as-is, because every character matters here. 🫢

πŸŽ€ ARGUMENTS πŸŽ€

  • nr β€” bit to set. You're picking the bit, bestie. πŸ’–
  • addr β€” address to count from. Yes, that's literally the description; no cap. πŸ™ˆ

πŸ”₯ DESCRIPTION πŸ”₯

This operation is atomic and provides acquire barrier semantics if the returned value is 0. That "if" is doing main-character work, so don't sleep on it. 😭

It can be used to implement bit locks. Iconic. πŸ’…

🌈 SEE ALSO 🌈


mwah πŸ’‹ this page comes from ./include/asm-generic/bitops, dated October 2026, and it's part of the Kernel API Manual. Go set that bit, bestie β€” atomic and cute. πŸŽ€βœ¨

πŸ“¦ where this page comes from