8 Temmuz 2012 Pazar

What is a Deadlock?

To contact us Click HERE
In a multiprogramming operating system, resources, such as I/O device, CPU cycle, and memory are used by multiple number of processes. There can be multiple number of instances of a resource. For example, there can be two printers attached to a computer. Resource sharing among various processes becomes an important aspect. In a computer system, a deadlock occurs when two or more processes attempt to access a resource that the other process has locked and hence cannot be shared. As a result, each process waits for a resource that the other has locked, and neither transaction can finish.

The flow of using a resource by a process occurs in a typical sequence. First, a process requests the operating system to allocate a resource. If the resource is available, operating system allocates the resource to that process. A process can acquire and lock a resource in exclusive or shareable mode. If a process locks a resource in shareable mode, operating system allows other processes to access that resource. If a process locks a resource in exclusive mode, no other process is allowed to access that resource.

The process waits until an instance of the requested resource becomes free, if all the instances of the requested process are engaged with other processes. A process can also request for multiple numbers of instances of a processes but it must be less than total number of resources. For example, if a computer has two printers, no process can request three or more printers.

The above-mentioned procedure occurs in normal situation, when there is no deadlock. On the other hand when a deadlock situation arises, the processes never complete their execution.
Conditions for Deadlock

There are four conditions that cause the occurrence of a deadlock.
Mutual Exclusion:

One or more resources should be acquired in exclusive mode. In other words, the concept of mutual exclusion depicts that a resource can be utilized by one process at a time.
Hold and Wait:

The processes involved in a deadlock, acquires at least one resource in exclusive mode and wait for at least another resource that has been acquired by another resource in exclusive mode.
No Preemption:

Processes do not release the resources allotted to them voluntarily without utilizing the resources.
Circular Wait:

A closed chain or a circular relationship exists among the processes involved in a deadlock.
Deadlock and Starvation

A deadlock is different from starvation. In starvation, a process waits for a resource that repetitively becomes free, but is always allotted to another process. In deadlock, resources are allotted to processes, which hold them until they release them voluntarily after utilizing the resource. The acquired resources remain unused because one or more resources required to complete this process are acquired by processes.

Hiç yorum yok:

Yorum Gönder