← Questions
Reusable cyclic barrier
0
I was asked this
No reports yet. Sign in to say where you were asked it.
Implement a barrier for a fixed number of threads. Each thread calls wait() at a sync point and blocks until all of them have arrived; then all are released together and the barrier resets itself for the next round. Build it from a mutex and condition variables. Handle spurious wakeups, and make sure a fast thread that loops around and calls wait() again cannot slip into the previous round (a generation counter is the usual fix).
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
