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.

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.

HardSystem Design
57 practiced

Design a mutex that supports priority inheritance. What state does it keep, how do acquire and release work, and how do you handle nested locks and bound the priority adjustments?

MediumTechnical
46 practiced

Where operating-system priority inheritance is unavailable or unsuitable, how do you prevent or soften priority inversion? Give application-level design changes and scheduler or deployment options.

HardTechnical
59 practiced

A privileged agent checks that a user may read a file and then opens it in a separate step. Explain how concurrency lets an attacker exploit the gap, and how you would redesign the access so the check and the use cannot be separated.

HardSystem Design
62 practiced

Design a thread-safe ordered set supporting insert, remove, contains and in-order iteration with weakly consistent semantics, plus snapshot views. How do you synchronize it (coarse, fine-grained, optimistic or lock-free), what guarantees does an iterator give while writers run, and how do you reclaim removed nodes safely?

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.