Table of Contents
qthread_lock, qthread_unlock - lock or unlock an address
#include
<qthread/qthread.h>
int
qthread_lock(qthread_t *me, aligned_t *addr);
int
qthread_unlock(qthread_t *me, aligned_t *addr);
These functions
are designed to implement FEB-like locking and unlocking that behaves much
more like a mutex.
These are atomic and functional, but do not have the
same semantics as full FEB locking/unlocking (namely, unlocking cannot
block), however because of this, they have lower overhead.
This function
takes a qthread_t pointer as an argument (me), which is supposed to point
to the qthread_t relating to the currently executing qthread. If the me
argument is NULL, the correct value will be discovered by the library via
a qthread_self() call, but the lookup may be expensive.
On success,
the memory address addr is marked locked or unlocked appropriately and
0 is returned. If unlocking an address that is already unlocked, QTHREAD_REDUNDANT
will be returned. On error, a non-zero error code is returned.
- ENOMEM
- Not enough memory could be allocated for bookkeeping structures.
qthread_empty(3)
,
qthread_fill(3)
, qthread_writeEF(3)
, qthread_writeF(3)
, qthread_readFF(3)
,
qthread_readFE(3)
Table of Contents