qthread_lock/unlock(3)
π 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:
qthread_empty(3)qthread_fill(3)qthread_writeEF(3)qthread_writeF(3)qthread_readFF(3)qthread_readFE(3)
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
- fedora 43: qthreads-devel 1.22^20251007gitcedb1fc-1.fc43 Β· BSD-3-Clause AND MIT AND dtoa
- fedora 44: qthreads-devel 1.22^20251007gitcedb1fc-2.fc44 Β· BSD-3-Clause AND MIT AND dtoa
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms