Wait until all futexes are available?
Wait until all futexes are available?
Posted Jun 30, 2020 15:42 UTC (Tue) by ncm (guest, #165)In reply to: Wait until all futexes are available? by itsmycpu
Parent article: Rethinking the futex API
Bits are set by compare-and-swap. atomically, with no system call needed.
To do it with a counter, the producer atomically decrements a counter, and wakes the thread when it sees the transition to zero.
Waking the thread might mean writing a byte to a pipe it is sleeping on.
Or, the producer's thread might just add the consumer to a scoreboard of runnable tasks, and some already-running thread will get to it. That way, the kernel is never involved at all. You keep exactly as many threads as you have cores on the job, and they spin when there is no work. Isolate those cores (isolcpus, nohz_full, rcu_nocbs) so the kernel does not steal them.
