InterviewStack.io LogoInterviewStack.io

Concurrency and Synchronization Questions

Covers the principles and practical techniques for safely coordinating concurrent execution and access to shared resources. Topics include models of concurrency such as threads, processes, interrupt handlers, and tasks in a real time operating system; differences between preemptive and cooperative scheduling; shared data hazards including race conditions and read modify write hazards; critical sections and approaches to protect them including disabling interrupts in embedded contexts and scoped locks. Synchronization primitives and patterns are included: mutexes, binary semaphores, counting semaphores, condition variables, message queues, atomic operations and lock free primitives such as compare and swap. Memory ordering concerns and memory barrier usage on multi core systems are covered, along with priority inversion and priority inheritance. Also addressed are deadlock, livelock, and starvation concepts and avoidance strategies, granularity and performance trade offs of locking, and practical synchronization patterns. Preparation should include identifying and fixing races in code, designing correct concurrent interfaces, and debugging and testing techniques such as stress testing, instrumentation, deterministic replay, race detectors, static analysis, and code review strategies.

HardTechnical
0 practiced
You observe a livelock where many threads continuously retry but make no progress (for example, CAS-based retry loops with no backoff). Describe how to debug and fix such livelock, provide a code pattern that causes livelock, and propose robust fixes including algorithmic and runtime strategies.
MediumTechnical
0 practiced
How can heap and CPU profiling help diagnose synchronization bottlenecks such as hot locks or contention hotspots? Describe the metrics to look for, how to attribute time blocked on locks to call stacks, and name Linux and language-specific tools you would use in production to gather this information with minimal overhead.
MediumTechnical
0 practiced
Explain read-modify-write hazards and illustrate with a C code example where non-atomic increments cause lost updates across threads. List atomic primitives available in modern C/C++ standards and mention which hardware instructions typically implement them.
EasyTechnical
0 practiced
Implement a thread-safe counter in Go without using `sync.Mutex`, by using a dedicated goroutine that owns the state and channels for requests. Provide a short code sketch for `Inc()` and `Value()` operations and explain the trade-offs between this approach and a mutex-based solution in production servers.
MediumTechnical
0 practiced
Design instrumentation to detect increasing lock contention in production over time for a core service. What metrics would you collect (examples: lock hold time histogram, wait time percentiles, number of blocked threads), how would you visualize them, and what automated alerts or thresholds would you configure to notify SREs before customer impact?

Unlock Full Question Bank

Get access to hundreds of Concurrency and Synchronization interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.