deadlock

  • In multi-programming surroundings, many processes could vie for a finite set of resources. 
  • A process request resource, if the resource is available they are allocated to the process otherwise the process enters the wait state. It may happen that the waiting process will never again change their state because other waiting processes hold the resource they have requested. This situation is called a deadlock.
  • The deadlock could be a state of affairs during which 2 processes sharing a similar resource square measure effectively preventing one another from accessing the resource, leading to each process.
EXAMPLE:-
  • Resource A is holding process 1.
  • Process 1 is requesting resource B.
  • Resource B is holding process 2.
  • Process 2 is requesting resource A.
EXAMPLE OF DEADLOCK
EXAMPLE OF DEADLOCK

Condition of deadlock

There are four conditions of deadlock:-
  1. Mutual exclusion condition.
  2. Hold and wait for the condition.
  3. No-preemption condition.
  4. Circular wait condiation.

1.  Mutual exclusion condition 

A resource that can't be employed by over one method at a time.

2.  Hold and wait condition

There must be one process that is holding one resource and waiting for another resource currently held by another process.
OR
The process of already holding resources may request new resources.

3.  No-preemption condition

No-preemption can not be forcefully removed from a process holding it.

4.  Circular wait condition

The must be a circular chain of two or more processes each of which requires hold by another member of the chain.
Circular-wait-condition
Circular wait condition