Deadlocks in OS
Deadlocks in OS
A deadlock, also called as deadly embrace, is a situation in which two threads are each
unknowingly waiting for resource held by other. Example #1 A system has 2 disk drives P1
and P2 each hold one disk drive and each need the other one. Task #1 wants the scanner while
holding the printer.
Deadlock can be prevented by eliminating any of the four necessary conditions, which are
mutual exclusion, hold and wait, no preemption, and circular wait. Mutual exclusion, hold
and wait and no preemption cannot be violated practically.
A deadlock in OS is a situation in which more than one process is blocked because it is holding
a resource and also requires some resource that is acquired by some other process. The four
necessary conditions for a deadlock situation to occur are mutual exclusion, hold and wait,
no preemption and circular set.