Questions: Barrier Synchronization Primitives

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A parallel matrix multiplication program uses multiple threads, each computing one row of the result matrix. Afterward, a normalization pass divides every element by the matrix's maximum value. A programmer wraps each row computation in a mutex to protect shared state. Does this correctly ensure the normalization pass sees all rows computed?

AYes — mutexes ensure ordered access, so the normalization thread cannot read a row until it is fully written
BNo — a barrier is needed here; mutexes protect shared data from concurrent access but do not prevent the normalization thread from starting before all row-computing threads have finished their rows
CYes — mutexes prevent any concurrent execution, so normalization cannot begin while rows are in progress
DNo — only semaphores can coordinate between computation phases; mutexes only work within a single phase
Question 2 Multiple Choice

In a simple centralized barrier implementation, the last thread to arrive at the barrier increments the counter to N and then calls broadcast on a condition variable rather than signal. Why broadcast?

ABroadcasting is faster than signaling for groups larger than two threads
BSignal wakes exactly one waiting thread; broadcast wakes all of them — all N-1 threads waiting at the barrier need to be released simultaneously, not just one
CBroadcasting automatically resets the counter to zero, which signaling cannot do
DBroadcasting guarantees FIFO ordering among threads leaving the barrier
Question 3 True / False

A barrier can replace a mutex to protect a shared data structure from concurrent writes, since both are synchronization primitives.

TTrue
FFalse
Question 4 True / False

A centralized barrier (one shared counter, one mutex, one condition variable) can become a performance bottleneck when the thread count is very large, because all threads must contend for the same lock.

TTrue
FFalse
Question 5 Short Answer

Why do iterative parallel simulations (like finite-element solvers or physics simulations) require barriers rather than just mutexes to produce correct results?

Think about your answer, then reveal below.