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
55 practiced

Explain the ABA problem using a pop from a lock-free stack. Why can a compare-and-swap succeed and still corrupt the structure, and how can it be prevented?

EasyTechnical
59 practiced

What does lock-free mean? Contrast lock-free with wait-free and obstruction-free guarantees, and explain when the extra complexity is worth it.

HardTechnical
57 practiced

Explain acquire and release semantics and how they differ from sequential consistency. Give an example where a weaker ordering permits a reordering that the stronger one prevents, and say what the performance trade-off is.

HardSystem Design
47 practiced

Design a work-stealing scheduler for parallel tasks, like a fork-join pool. What does each worker's deque look like, which end does the owner use and which end do thieves use, how is a steal made safe without a global lock, and what keeps contention low?

MediumTechnical
46 practiced

Implement a lock-free stack with push and pop using compare-and-swap on the head pointer. What correctness concerns do you have, and how does the language runtime change them?

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.