Wednesday 9 November 2016

DeadLock in Operating System

By
Praveen


Deadlock is a specific condition in Operatin System when two or more processes are each waiting for another processer to release resource, or more than two processes are waiting for to get resources in a circular chain. Deadlock is a most common problem in multiprocessing where many processes share a specific type of mutually exclusive resource known as a software, or soft, lock.

If there are two processor P1, P2. And resources are R1, R2.
Resource R1 is assign to P1 and R2 is assign to R2.
Processor P1 is having resource R1 and requested P2 to release resource R2.
Processor P2 is having resource R2 and requested P1 to release resource R1.
So this situation is Deadlock.

There are four conditions for a deadlock to occurs. This conditions are  known as the Coffman conditions
1. Mutual exclusion condition  : A resource must use only  for one  process at a time
2. Hold and wait condition       : A Processes already hold a resources  and requesting  new resources
3. No pre-emption condition    : Only a process holding a resource may release it
4. Circular wait condition        : Two or more processes in the form of  circular chain where each process waiting  for a resource that the next process in the chain holds

Deadlock can occur in system if there all of 4 conditions hold true.

Avoidance :
We can avoid Deadlock if certain information about processes and allocated resources are available in advance of resource allocation.
Two other algorithms are Wait/Die and Wound/Wait, each of which uses a symmetry-breaking technique. In both these algorithms there exists an older process (O) and a younger process (Y). Process age can be determined by a time stamp at process creation time. Smaller time stamps are older processes, while larger timestamps represent younger processes.

                                                   Wait/Die    Wound/Wait
O needs a resource held by Y         O waits       Y dies
Y needs a resource held by O         Y dies         Y waits

No comments:

Post a Comment