Search

Deadlock

Introduction of Deadlock in OS

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 may be a situation where a group of processes are blocked because each process is holding a resource and expecting another resource acquired by another process
Deadlocks
Deadlock in sql server
.

Consider an example when two trains are coming toward one another on same track and there's just one track, none of the trains can move once they're ahead of every other. Similar situation occurs in operating systems when there are two or more processes hold some resources and await resources held by other(s). for instance , within the below diagram, Process 1 is holding Resource 1 and expecting resource 2 which is acquired by process 2, and process 2 is expecting resource 1.

Deadlock can arise if following four conditions hold simultaneously (Necessary Conditions)
Mutual Exclusion: One or quite one resource are non-sharable (Only one process can use at a time)
Hold and Wait: A process is holding a minimum of one resource and expecting resources.
No Preemption: A resource can't be taken from a process unless the method releases the resource.
Circular Wait: a group of processes are expecting one another in circular form.


Methods for handling deadlock:-


deadlock

There are 3 ways to handle deadlock

  1. Deadlock prevention or avoidance: the thought is to not let the system into deadlock state.One can zoom into each category individually, Prevention is completed by negating one among above mentioned necessary conditions for deadlock. Avoidance is quite futuristic in nature. By using strategy of “Avoidance”, we've to form an assumption. we'd like to make sure that each one information about resources which process WILL need are known to us before execution of the method . We use Banker’s algorithm (Which is in-turn a present from Dijkstra) so as to avoid deadlock.
  2.  Deadlock detection and recovery: Let deadlock occur, then do preemption to handle it once occurred.
  3.  Ignore the matter all together: If deadlock is extremely rare, then let it happen and reboot the system. this is often the approach that both Windows and UNIX take.

Post a Comment

0 Comments