Deadlock in OS

If two or more processes are waiting for happening of some event which never happens then we say these processes are involved in deadlock and the state will be the deadlock state in OS.

If all of the following four conditions fulfill the current situation then deadlock will be occur if any one condition false then there will be no deadlock. 

1. Mutual Exclusion (Never Share Resource)

Only one process can use the any resource at a time. If there are two process P1, and P2, Where a resource R1 is allocated to P1 and P2 request for R1 at the same time. Then P1 never share the resource R1 with process P2 because condition of mutual exclusion is that only one processes can use at a time one Resource.

Cooperative processes cannot use the critical section at the same time.

2. No Preemptive

If a process P1 holds a resource then it will never release it for upcoming process P2 which also demand for the same resource which is already allocated to P1.

3. Hold And Wait

If a process P1 holds a resource and upcoming process P2 also demand for the same resource which is already allocated to P1. Then P2 have to wait until P1 release the resource.

4. Circular Wait

deadlock - eliminate circular wait

There exist a set of processes (P1, P2, P3……PN). Where P1 is waiting for P2 and P2 is waiting for P3 and so on until PN. And PN is waiting for P1 in the last.

Deadlock Vs. Starvation in OS

Deadlock Starvation
1. In Deadlock situation,no further process block and no process execute. 1. In Starvation all the low priority processes are blocked and the all high priority processes are executed.
2. Deadlock is infinite time waiting. 2. Starvation is long time waiting but not infinite.
3. Every Deadlock is always a starvation. 3. Every starvation may not be deadlock.
4. The requested resource is blocked by the other process. 4. The requested resource is continuously used by the higher priority processes.
5. Deadlock occur when following four conditions fulfill at the same time.
  • Mutual exclusionNo preemption hold and waitcircular wait
5. It may occurs due to resource management and having no control on priority of processes etc.

Deadlock in OS can be Handled through the following Methods

1. Deadlock Ignorance 
2. Deadlock Prevention
3. Deadlock Avoidance
4. Deadlock Reduction
5. Deadlock Recovery

Help Other’s By Sharing…

Contact Us

Burewala, Vehari, Punjab, Pakistan

cstaleem1@gmail.com

Website: CStaleem.com

Pin It on Pinterest