Header Ads Widget

Deadlock Prevention in Operating System

Dealing with Deadlock Situations: Deadlock Prevention    

This artical explores the concept of deadlock prevention in operating system. Four conditions must hold simultaneously for a resource deadlock to arise in a system. These conditions are :

1. Resources are non-sharable.
2. Processes hold some resources, as they wait for other resources.
3. It is not feasible to preempt resources from the processes.
4. A circular chain of hold and wait condition exist in the system.

Deadlock can be prevented if the kernel uses a resource allocation policy that ensures that one of these conditions can not arise.

Examination of mutual exclusion:

A mutual exclusion condition must hold for non sharable resources. For example, a printer can not be simultaneously shared by several processes.We can not prevent deadlock by denying the mutual exclusion condition because some resources are intrinsically non-sharable.

Examination of hold and wait :

When a process requests a resource, it does not hold any other resources. By this way hold and wait condition never occur in the system.

One protocol that can be used requires each process to request and be allocated all its resources before it begins execution. An alternative protocol allows a process to request resources when process has no resource. Before it requests any additional resource, it must release all the resources that it is currently allocated. But these protocols have two main disadvantages-

(i) Resource utilization may be low.
(ii) Starvation is possible.

Examination of no preemption:

If a process requests some  resources, we first check whether they are available. If they are,  we allocate them. If they are not available, we check whether they are allocated to some other process that  is waiting for additional resources. If so, we preempt the desired resources from the waiting process and allocate them to requesting process. If the resources are not either available or held by waiting process, the requesting process must wait. While it is waiting, some of its resourcesmay be preempted, but only if another process requests them. A process can be restarted only when it is allocated the new resources it is requesting and recovers any resources that were preempted while it was in waiting state. 

Examination of circular wait:

In order to ensure that the circular wait condition never holds, we may improve total odering of all resource types and to require that each process requests resources in an increasing order of enumeration. In this method resources can be numbered. Processes can request resources whenever they want to, but all requests must be made in numerical order.  Here the numbering should be done appropriately. The problem with this strategy is that it is difficult to find an ordering that satisfies everyone.


Post a Comment

0 Comments