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

What is starvation? Describe a situation in a service where one class of work never gets to run, and explain how you would mitigate it.

MediumTechnical
63 practiced

A production service hangs. Thread dumps show many threads blocked on locks. How do you confirm a deadlock versus a livelock or priority inversion, what do you collect, and how do you recover and prevent a repeat?

HardTechnical
62 practiced

An intermittent concurrency bug appears only under heavy production load. How do you reproduce it and find the root cause? Cover instrumentation, stress, race detectors and deterministic replay.

MediumTechnical
53 practiced

Show a minimal example in code where two threads acquire two locks in opposite order and deadlock. Then fix it, and explain how you would detect and reproduce this in a live system.

MediumTechnical
60 practiced

How do you use a dynamic race detector on production-like workloads? Cover overhead, false positives, workload representativeness and where static analysis fits, so cost and coverage stay balanced.

That is every published Concurrency, Synchronization & Deadlock question for Site Reliability Engineer (SRE) so far. Browse the other topics in this category, or practice this one interactively.