Introduction to Deadlocks:


Definition and Explanation:

In a multiprogramming environment, several processes compete for resources. A situation may arise where a process is waiting for a resource that is held by other waiting processes. This situation is called a deadlock.


A system has a finite set of resources such as memory, I/O devices, etc. It also has a finite set of processes that need to use these resources. A process that wishes to use any of these resources, makes a request to use that resource. If the resource is free the process gets it. If it is being used by another process, it waits for it to become free. The assumption is that the resource will eventually become free and the waiting process will then use the resource. But in some situations, the other process may also be waiting for some resource.


"A set of processes is in a deadlock state when every process in the set is waiting for an event that can only be caused by another process in the set."


Suppose we have two tape drives and two processes. Each process has got one tape drive for each process, but both need two such tape drives to proceed with execution. Each is waiting for the other process to release the other tape drive. This will never happen as the other is also waiting for the same thing. This situation is a deadlock.


Deadlock Examples:


Following are some examples of deadlock.


Example 1:


The following figure is of a traffic deadlock. It makes the nature of deadlock very clear. None of the cars can pass unless at least one of them backs up or is removed.


Example 2:


When two trains approach each other at a crossing, both shall come to a full stop and neither will start up again until the other has gone.


Example 3:


Suppose we have, a printer and a tape drive. Process A requests for the printer and gets it. Process B requests tape drive and it is granted to it. Now A asks for the tape drive but the is denied until B releases it. At this point, the process B asks for the printer before the tape drive.


Now both processes are waiting for each other to release the resource and are blocked. Both processes will remain in this situation forever. This situation is called deadlock.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Blog Archive

Powered by Blogger.

- Copyright © 2013 Taqi Shah Blogspot -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -