Table of Contents


qthread_syncvar_writeEF, qthread_syncvar_writeEF_const - waits for the dest syncvar to be empty, then fills it


#include <qthread.h>

qthread_syncvar_writeEF (syncvar_t * restrict dest, const uint64_t * restrict src);

qthread_writeEF_const (syncvar_t *dest, uint64_t src);


These functions wait for the dest syncvar to become empty, and then fill it. When dest becomes empty, only one thread blocked like this will be awoken. Data is read from src and written to dest. The data in src MUST be small enough to fit in the syncvar_t.

The semantics of writeEF are:

1 - dest’s FEB state must be "empty"
2 - data is copied from src to dest
3 - dest’s FEB state gets changed from "empty" to "full"

Return Value

On success, the memory address dest is marked full, the address dest is filled with the contents of src and 0 (QTHREAD_SUCCESS) is returned. On error, a non-zero error code is returned.


Not enough memory could be allocated for bookkeeping structures (when blocking).
The value specified in src could not be stored in the syncvar_t. On most platforms, syncvar_t can only store 60 bits of data, despite occupying 64 bits of memory, because four bits are reserved for status information.
Could not obtain the lock on the syncvar_t’s status bits. This may be caused by many things, including memory corruption, invalid syncvar, or even absurdly excessive contention (because its protected by a naive spinlock rather than a fair spinlock).

See Also

qthread_syncvar_empty(3) , qthread_syncvar_fill(3) , qthread_syncvar_writeF(3) , qthread_syncvar_readFF(3) , qthread_syncvar_readFE(3) , qthread_syncvar_status(3)

Table of Contents