3 ms·
> Relying heavily on a check for an atomic bool is prone to race conditions. It is not, actually. This extremely simple protocol is race-free.
by loeg 1y ago
> Relying heavily on a check for an atomic bool is prone to race conditions.
It is not, actually. This extremely simple protocol is race-free.
- krackers 1y agoCalling pthread_cond_signal without acquiring mutex can lead to lost wakeup. And of course you can't really acquire a mutex in an async signal safe function like interrupt handler. Without the signaling thread acquiring a mutex, you might end up signaling after T2 has checked the boolean, but before it has called cond_wait. But this can be solved by processing the async signal in a deferred manner from some other watcher thread