qthread_syncvar_writeF(3)

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

πŸ’– qthread_syncvar_writeF(3) πŸ’–

okay bestie, so this is a page from libqthread and it's literally about stuffing data into a syncvar_t. the functions are qthread_syncvar_writeF and qthread_syncvar_writeF_const. let's get into it 🫢


✨ NAME ✨

qthread_syncvar_writeF, qthread_syncvar_writeF_const β€” fills a syncvar_t with data πŸ’…


🌸 SYNOPSIS 🌸

#include <qthread.h>

int
qthread_syncvar_writeF (syncvar_t * restrict dest, const uint64_t *
restrict src);

int
qthread_syncvar_writeF_const (syncvar_t *dest, uint64_t src);

πŸ¦‹ DESCRIPTION πŸ¦‹

so these two are like… the lovechild of qthread_syncvar_fill() and qthread_syncvar_writeEF(). they're giving hybrid energy. ✨

here's the thing: they do not wait around for the memory to become empty. nope. they just do the write and set the state to full atomically (atomically with respect to other syncvar_t actions, that is β€” no cutting in line πŸ’…). data gets read from src and written to dest. periodt.

the semantics of writeF are, in order:

  1. data is copied from src to dest
  2. dest's FEB state gets set to "full"

πŸŽ€ RETURN VALUE πŸŽ€

on success: the memory address dest is marked full, dest gets filled with the contents of src, and 0 (QTHREAD_SUCCESS) is returned. slay. πŸŽ‰

on error: a non-zero error code comes back at you. not slay. 😭


πŸ’€ ERRORS πŸ’€

  • ENOMEM β€” not enough memory could be allocated for bookkeeping structures. the vibes were not immaculate. πŸ™ˆ
  • EOVERFLOW β€” the value you put in src just could not be stored in the syncvar_t. on most platforms, syncvar_t can only store 60 bits of data, even though it takes up 64 bits of memory, because four bits are reserved for status information. so yeah, it's giving "no room bestie" 🚫
  • QTHREAD_TIMEOUT β€” could not obtain the lock on the syncvar_t's status bits. this may be caused by many things, including memory corruption, an invalid syncvar, or even absurdly excessive contention (because it's protected by a naive spinlock rather than a fair spinlock). lowkey chaotic honestly.
⚠️ real talk: that QTHREAD_TIMEOUT one is a whole situation. naive spinlock, no fairness, so a crowd of threads can just absolutely body it. if you see this error, don't assume it's your fault β€” memory corruption and invalid syncvars are on the list too. 🫠

🌈 SEE ALSO 🌈


and that's the whole page, bestie! this icon of a manpage came from libqthread, dated APRIL 2011 β€” yeah, she's vintage, but she still ate πŸ’…βœ¨ go forth and write your syncvars, and remember: writeF does not wait, it just goes. πŸ‘‘πŸ’–

πŸ“¦ where this page comes from