What this C++ reader–writer synchronisation question tests
This is a medium-difficulty concurrency question that examines your understanding of thread safety and synchronisation primitives in C++. It asks you to reason about what happens when multiple reader threads and a single writer thread compete for access to a shared resource, and which synchronisation approaches are correct.
To answer questions like this, you need to understand the semantics of locks, mutexes, and read–write coordination patterns. The question rewards precise knowledge of which C++ concurrency constructs guarantee mutual exclusion, which permit concurrent reads, and which prevent data races under the specific access pattern described. Common pitfalls include confusing the behaviour of standard locks with reader–writer locks, or misunderstanding when synchronisation is necessary.
- Mutual exclusion and critical sections
- Read–write lock semantics versus standard mutexes
- Data races and thread safety guarantees
- Lock ordering and deadlock prevention