Explain deadlock? What are necessary conditions for deadlock?

In multiprogramming environment, several processes may compete for a finite
number of resources. A process requests resources and if the resources are not
available then the process enters into the waiting state. Sometimes a waiting
process is never again able to change its status because the resources requested
by it are held by other waiting processes. This situation is called as deadlock.
When a process request for resources held by another waiting process which in
turn is waiting for resources held by another waiting process and not a single
process can execute its task, then deadlock occurs in the system.
Example: Consider a system with three disk drives and three processes. When
each process request one disk drive, system allocates one disk drive to each
process. Now there is no more drive available in the system. If all three
processes request for one more disk drive, then all three processes will go into
the waiting state and system will go in deadlock state. Because any one process
from the three can execute only when one of them will release the disk drive
allocated to it.
Necessary Conditions:
1. 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.
2. Hold and Wait: A process must be holding at least one resource and
waiting to acquire additional resources that are currently being held by
0 Comments