A deadlock is a state where a set of tasks are each blocked waiting for a resource that another task in the set holds, so none of them can ever proceed, the system (or that subset of it) is frozen permanently. The classic example is two tasks and two mutexes acquired in opposite orders: Task A takes lock1 then tries to take lock2, while Task B takes lock2 then tries to take lock1. If A acquires lock1 and B acquires lock2 before either gets the second, A blocks waiting for lock2 (held by B) and B blocks waiting for lock1 (held by A), a circular wait with no way out, because each is waiting for the other to release, and neither will. The defining feature is the cycle in the wait-for graph. It's distinct from priority inversion (where the high task would eventually run once the holder finishes), in a deadlock no one ever finishes. In embedded systems a deadlock typically manifests as tasks silently stopping and, often, a watchdog reset because a task missed its deadline.
RTOS & Real-Time Concepts · Interview question
What is a deadlock and what's the classic example?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
Deadlocks & How to Avoid Them
Two tasks each holding a lock the other needs, frozen forever: the four conditions for deadlock, and the fixes (consistent lock ordering, avoiding hold-and-wait, and timeouts).