Deadlock occurs when a set of processes are blocked, each holding a resource while waiting for another. Four necessary conditions for deadlock include mutual exclusion, hold and wait, no pre-emption, and circular wait. To handle deadlocks, methods such as deadlock prevention and deadlock avoidance, like the Banker's algorithm, can be employed.
Deadlock occurs when a set of processes are blocked, each holding a resource while waiting for another. Four necessary conditions for deadlock include mutual exclusion, hold and wait, no pre-emption, and circular wait. To handle deadlocks, methods such as deadlock prevention and deadlock avoidance, like the Banker's algorithm, can be employed.
blocked because each process is holding a resource and waiting for another resource acquired by some other process.
Necessary conditions for a deadlock
A deadlock situation can arise if the following four
conditions hold simultaneously in a system. 1.Mutual exclusion- At least one resource must be held in a non-sharable mode. That is only one process at a time can use the resource. 2. Hold and wait-There must exist at least one resource and is waiting to acquire additional resources that are currently being held by other processes. 3.No pre-emption- Resources cannot be pre-empted. That means a resource can be released only voluntarily by process holding it, after that process has completed its task. 4.Circular wait-There must exist a set of processes {P0, P1, P2…. Pn } of waiting processes such that P0 is waiting for a resource held by P1, P1 is waiting for a resource held by P2,…..Pn-1 is waiting for a resource held by Pn and Pn is waiting for a resource held by P0.
Methods for handling deadlocks
1. Deadlock prevention- It is a set of methods for ensuring that at least one of the necessary conditions cannot hold.
2. Deadlock avoidance- requires that the operating
system be given in advance additional information concerning which resources a process will request and use during its lifetime. Bankers algorithms is a deadlock avoidance algorithm.