Concurrency, Synchronization & Deadlock Questions
Coordinating concurrent execution against shared state: mutexes, semaphores, condition variables, spinlocks, and atomic operations, plus the problems they solve and cause. Covers race conditions, critical sections, the classic deadlock conditions and prevention/avoidance strategies, priority inversion, and livelock at the OS level.
Explain key differences in memory ordering models between ARMv7-M (Cortex-M) and ARMv8-A (Cortex-A) or x86. Give two concrete examples where forgetting to use a DMB/DSB on ARM leads to incorrect results, particularly in DMA and inter-core communication.
A shared 64-bit timestamp counter is read in the main thread but updated in an ISR on a 32-bit microcontroller. Identify the potential atomicity issue and present at least two ways to safely read and update the 64-bit counter without using 64-bit atomic hardware support.
Compare and contrast mutex, binary semaphore, and counting semaphore in an embedded RTOS. For each primitive describe ownership semantics, blocking behavior, and whether it is safe to use from an ISR. Give one example use-case for each primitive in a sensor-driven IoT device.
Walk through a priority inversion scenario on an RTOS: low-priority task L holds a mutex, high-priority task H blocks on that mutex, and medium-priority task M preempts L. Show the sequence of events and explain how priority inheritance fixes the problem. Describe conditions where priority inheritance may not be enough and what protocol alternatives exist.
Implement a bounded producer-consumer buffer using semaphores and a mutex in FreeRTOS-style pseudocode. Show producer and consumer tasks with blocking behavior and support for optional timeout on produce/consume. Note constraints about calling from an ISR and how to signal from ISR to task.
Unlock Full Question Bank
Get access to all 35 Concurrency, Synchronization & Deadlock interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.