Concurrency, Synchronization & Deadlock Questions

Correctness of shared-state coordination between concurrent threads and tasks. Covers mutexes (futex-based and spin-then-sleep), semaphores, condition variables, spinlocks, reader-writer locks, and the producer-consumer pattern; atomic operations, compare-and-swap, lock-free and wait-free structures with the ABA problem and safe memory reclamation; memory ordering, barriers and acquire/release semantics; race conditions, data races, critical sections, time-of-check to time-of-use gaps and read-modify-write hazards; deadlock (the Coffman conditions, lock ordering, prevention and detection), livelock and starvation; priority inversion as a locking hazard and the priority-inheritance fix; designing thread-safe structures such as bounded queues, caches, rate limiters, event buses and work-stealing schedulers, with coarse versus fine-grained and per-key locking; alternatives to locking such as thread confinement, message passing, actors and transactional memory; and diagnosing and testing concurrency bugs (heisenbugs, race detectors, stress and replay, reviewing concurrent code). Excludes a specific language's threading API and memory model, concurrency for throughput and pool tuning, distributed locks and consensus, database isolation levels, RTOS ceiling protocols and schedulability, and interrupt masking between ISRs and main code.

MediumTechnical
51 practiced

How do you test concurrent code systematically? Cover unit, stress and integration approaches, and how you reduce flakiness in CI while still exposing real races and deadlocks.

EasyTechnical
55 practiced

How can thread confinement and message passing help you avoid locks? Give an example of confining state to one thread or queue, and say when you would still need synchronization.

EasyTechnical
91 practiced

Two threads each run counter += 1 on a shared integer many times, and the final total is sometimes too low. Explain exactly how the interleaving loses updates, and show how you would fix it. When would you choose a lock and when an atomic?

EasyTechnical
51 practiced

One thread appends to a shared list while another iterates over it and removes elements. Describe the data race, what failures you would actually see, and how you would fix it without making iteration painfully slow.

HardTechnical
64 practiced

A concurrency bug disappears when you add logging, or only occurs in release builds on one device. Why does that happen, and how do you still reproduce it deterministically?

Unlock Full Question Bank

Get access to all 7 Concurrency, Synchronization & Deadlock interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.