← Questions

Reusable cyclic barrier

0
AppleCodingLast asked Aug 2026

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).

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