Deadlock Prevention

Filter Course


Deadlock Prevention

Published by: Zaya

Published date: 22 Jun 2021

Deadlock Prevention Photo

Deadlock Prevention

Deadlock prevention simply involves techniques to attack the four conditions that may cause deadlock (Coffman conditions) :

1. Prevention from Mutual exclusion

  • The resource should not be assigned to a single process until absolutely necessary.
  • For example: instead of assigning a printer to a process, we can create a spool (send (data that is intended for printing or processing on a peripheral device) to an intermediate store.), so that several processes can generate output at the same time.

2. Preventing the Wait and Hold condition

  • The process should request all of its required resources at the beginning.
  • If every resource is available, the process runs, or else it waits but does not hold any of the resources.
  • This way hold and wait condition are eliminated but it will lead to low device utilization.
  • For example, if a process requires a printer at a later time and we have allocated a printer before the start of its execution printer will remain blocked till it has completed its execution.

3. Preventing the non-preemption condition

  • Preempt resources from the process when resources required by another high priority process.

4. Preventing Circular Wait

  • Each resource will be assigned a numerical number. A process can request for the resources only in increasing order of numbering.
  • For Example, if the P1 process is allocated R5 resources, now next time if P1 asks for R4, R3 lesser than R5 such request will not be granted, only request for resources more than R5 will be granted.