Problem statement
Design a cyclic barrier: a synchronization point where a fixed number of threads (the parties) wait for one another, all release together, and the barrier rearms for the next round. It coordinates phased computation where every worker must finish phase k before any starts phase k+1.
Operating context. One process, N worker threads. Each calls await() at the end of a phase; when the Nth arrives the barrier trips, releases all parties together, and advances to a fresh generation for the next phase. An optional barrier action runs exactly once, on the last-arriving thread, before the others are released. A timed await must trip the barrier into a broken state on timeout or interruption so no party hangs waiting for a peer that will never arrive.
Out of scope. Distributed barriers, the phased work itself, changing the party count mid-generation beyond a defined reset, MPI-style collective operations, and any persistence.
What to produce. The class model (the barrier, a generation/phase token, the arrival counter, the optional barrier action), the public API, and the state transitions across a generation (filling, tripped, reset, and broken). Be explicit about why a generation object separates one round's waiters from the next, how the last arriver runs the action and releases everyone, and how a broken barrier fails every waiter cleanly.
Requirements
This assessment is a Premium feature.
The statement above is free to read. The functional and non-functional requirements, and the graded canvas that scores your design against them, come with Premium.
Topics
- System Design LLD
- Concurrency Synchronization
- Concurrency Condition-Variables
- Patterns State
- Oop Interface-Design