qthread_lock/unlock(3)

πŸ“¦ version 1.22^20251007gitcedb1fc, in fedora 43, fedora 44

πŸ’… qthread_lock / qthread_unlock β€” the manual page, but make it cute

okay bestie, we're in section 3 of the libqthread manuals and today's episode is all about locking and unlocking an address. yes, an actual memory address. no, it's not that deep, but also it kind of is. 🫢


✨ NAME ✨

qthread_lock, qthread_unlock β€” lock or unlock an address πŸ”’πŸ”“


🌸 SYNOPSIS 🌸

#include <qthread.h>

int
qthread_lock (aligned_t *addr);

int
qthread_unlock (aligned_t *addr);

πŸ¦‹ DESCRIPTION πŸ¦‹

so these two little icons are here to implement FEB-like locking and unlocking, except β€” plot twist β€” they behave way more like a mutex. it's giving glow-up. πŸ’–

they're atomic and they functional, fr fr, but lowkey they do not have the same semantics as full FEB locking/unlocking. the specific tea here: unlocking cannot block. that's the whole trade-off. πŸŽ€

and because of that little limitation? they have lower overhead. less drama, less cost, iconic behaviour honestly. ✨


πŸ”₯ RETURN VALUE πŸ”₯

when it works, the memory address addr gets marked locked or unlocked appropriately and you get back 0. 🫢

if you try to unlock an address that's already unlocked? bestie, that's fine, you get QTHREAD_SUCCESS back. no harm, no foul, no shame. 😌

on error, you get a non-zero error code. not zero. zero is the good one. remember that. πŸ’€


πŸ’€ ERRORS πŸ’€

  • ENOMEM β€” not enough memory could be allocated for the bookkeeping structures. the vibes were immaculate but the RAM said no. 😭

πŸ‘‘ SEE ALSO πŸ‘‘

go read these next, they're all in the group chat:


remember bestie: these are atomic and they work, but they are not full FEB locking/unlocking semantics β€” unlocking can't block, and that's by design, not a bug. don't come for me. πŸ’…

mwah, that's the whole page. this lil' beauty ships with libqthread and it's dated APRIL 2011 β€” vintage, honestly, and still slaying. πŸŒˆπŸ’œπŸŒΈ

πŸ“¦ where this page comes from