OS

Interview Questions on OS - Deadlock

1. what is deadlock?

Deadlock is a situation that when two or more process waiting for each other and holding the resource which is required by another process.

2. What are the necessary conditions to occur deadlock?

Mutual exclusion: At least one resource must be held in a nonsharable mode. that is, only one process at a time can use the resource. If another process requests that resource, the requesting process must be delayed until the resource has been released.
Hold and wait: A process must be holding at least one resource and waiting to acquire additional resources that are currently being held by other processes.
No preemption: Resources cannot be preempted.; that is, a resource can be released only voluntarily by the process holding it, after that process has completed its task.
Circular wait: A set {P$, Pi, ..., Pn\ of waiting processes must exist such that P-0 is waiting for a resource held by P\, P\ is waiting for a resource held by P?, •••, P.,--i is waiting for a resource held by Pn, and P,, is waiting for a resource held by Pn.

3. Explain about resource allocation graph?

Deadlocks can be described more precisely in terms of a directed graph called a system resource-allocation graph. If the graph contains no cycles, then no process in the system is deadlocked. If the graph does contain a cycle, then a deadlock may exist.

4. What are the methods to handle the dead locks?

1. We can use a protocol to prevent or avoid deadlocks, ensuring that the system will never enter a deadlock state.
2. We can allow the system to enter a deadlock state, detect it, and recover.
3. We can ignore the problem altogether and pretend that deadlocks never occur in the system.
The third solution is the one used by most operating systems

5. What is Bankers Algorithm.

it is an algorithm which used in a banking system to ensure that the bank never allocated its available cash in such a way that it could no longer satisfy the needs of all its customers.


www.000webhost.com