What is Barrier synchronization?
Synchronization in which threads that arrive first wait until all threads reach the same point, keeping them in step phase by phase. Distinct from a memory barrier.
Japanese name: バリア同期
Synchronization in which threads that arrive first wait until all threads reach the same point, keeping them in step phase by phase. Distinct from a memory barrier.
Japanese name: バリア同期
A parallel computation is sometimes advanced in phases. In each phase every thread computes its own share, and only when all have finished do they move to the next phase. In a simulation that steps time forward on a grid, for example, the next value at each point is computed from the current values of the surrounding points. If some threads move on before all have finished the current phase, old and new values become mixed. Placing a barrier at the boundary between phases keeps the threads in step.
A barrier counts the threads that have arrived and puts arriving threads to sleep until the count reaches a set number. When the last thread arrives, it wakes them all and resets the count to zero. Because the count is reset, the same barrier can be used again in the next phase. Thread libraries and parallel programming languages provide this form of synchronization. It may also be inserted automatically at the end of a parallel loop.
Every thread ends up waiting for the slowest one. If the amount of work is uneven among threads, the waiting time of those that finish early is wasted. If the phases are too fine, more time goes to the barrier than to the computation. When there are more threads than cores, everyone waits for threads that the operating system has suspended, which is especially slow.
Answer: B. Threads that arrive first wait at that point until all threads have arrived
In simulations and similar work, all threads must finish one step's computation before moving to the next. With barrier synchronization, each thread stops at the barrier, and when the last thread arrives they all proceed. If the workload is uneven, fast threads spend more time waiting for slow ones, so dividing work evenly matters for performance.
No. A memory barrier is an instruction that makes the processor keep memory operations in order. Only the names are similar; they are different things.
Waiting for a thread to finish waits until the thread has completed all its work. A barrier lines the threads up at an intermediate point without ending them and then lets them continue.
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.