Qualcomm interview question

Explain a situation where a deadlock would occur.

Interview Answers

Anonymous

28 Jun 2012

Two processes each holding a resource tries to access the other's resource.

1

Anonymous

15 Apr 2013

Or you could forget to unlock.

Anonymous

4 Jun 2013

There are 4 conditions from Coffman's: A deadlock situation can arise if all of the following conditions hold simultaneously in a system:[1] 1. Mutual Exclusion: At least two resource must be non-shareable.[1] Only one process can use the resource at any given instant of time. 2. Hold and Wait or Resource Holding: A process is currently holding at least one resource and requesting additional resources which are being held by other processes. 3. No Preemption: The operating system must not de-allocate resources once they have been allocated; they must be released by the holding process voluntarily. 4. Circular Wait: A process must be waiting for a resource which is being held by another process, which in turn is waiting for the first process to release the resource. In general, there is a set of waiting processes, P = {P1, P2, ..., PN}, such that P1 is waiting for a resource held by P2, P2 is waiting for a resource held by P3 and so on until PN is waiting for a resource held by P1.[1][7]