13 Dec 2019

  • December 13, 2019
  • Amitraj
Introduction of Deadlock in Operating System

-> A process in operating systems uses different resources and uses resources in following way.

1) Requests a resource
2) Use the resource
2) Releases the resource



-> Deadlock is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process.

-> Consider an example, when two trains are coming toward each other on same track and there is only one track, none of the trains can move once they are in front of each other. Similar situation occurs in operating systems when there are two or more processes hold some resources and wait for resources held by others. 

For example, in the below diagram, Process 1 is holding Resource 1 and waiting for resource 2 which is acquired by process 2, and process 2 is waiting for resource 1.






Necessary conditions for Deadlocks

 1. Mutual Exclusion

A resource can only be shared in mutually exclusive manner. It implies, if two process cannot use the same resource at the same time.


2. Hold and Wait

A process waits for some resources while holding another resource at the same time.


3. No Preemption 

A resource cannot be taken from a process unless the process releases the resource.


4. Circular Wait 

A set of processes are waiting for each other in circular form.


Translate

Popular Posts