Deadlock and its conditions to occur


Deadlock is a SERIOUS problem that can occur in concurrent systems, how do you - as OS designer and developer - control deadlock ?

Deadlock can exist if and only if 4 conditions hold simultaneously:

1. mutual exclusion: At least one resource must be held in a nonsharable mode.
2. hold and wait: There must be a process holding one resource and waiting for another.
3. no preemption: Resources cannot be preempted.
4. circular wait: There must exist a set of processes

There are three ways to handle the deadlocks:

1. Prevention and Avoidance of the deadlocks.
2. Allowing the deadlocks to occur and then detecting and correcting them consequently.
3. Assuming that deadlocks never occur in the system and ignoring them.