Deadlock Prevention

Deadlock prevention


Deadlock Prevention may be prevented by denying any one of the conditions. Prevent deadlock prevention by resource scheduling so as to negate at least one of the four conditions

  • Elimination of “Mutual Exclusion” Condition:

    The mutual exclusion condition must hold for non-sharable resources. That is, several processes cannot simultaneously share a single resource. This condition is difficult to eliminate because some resources, such as the Hard disc drive and printer, are inherently non-shareable. Note that shareable resources like read-only-file do not require mutually exclusive access and thus cannot be involved in the deadlock.

  • Elimination of “Hold and Wait” Condition:

    There are two possibilities for the elimination of the second condition. The first alternative is that a process request is granted all of the resources it needs at once, prior to execution. The second alternative is to disallow a process from requesting resources whenever it has previously allocated resources. This strategy requires that all of the resources a process will need must be requested at once. The system must grant resources on “all or none” basis. If the complete set of resources needed by a process is not currently available, then the process must wait until the complete set is available. While the process waits, however, it may not hold any resources. Thus the “wait for” condition is denied and deadlocks cannot occur. This strategy can lead to a serious waste of resources.

  • Elimination of “No-preemption” Condition:

    The non-preemption condition can be alleviated by forcing a process waiting for a resource that cannot immediately be allocated to relinquish all of its currently held resources, so that other processes may use them to finish. This strategy requires that when a process that is holding some resources is denied a request for additional resources. The process must release its held resources and, if necessary, request them again together with additional resources. Implementation of this strategy denies the “no-preemptive” condition effectively.

  • Elimination of “Circular Wait” Condition:

    The last condition, the circular wait, can be denied by imposing a total ordering on all of the resource types and then forcing, all processes to request the resources in order (increasing or decreasing). This strategy imposes a total ordering of all resources types, and to require that each process requests resources in a numerical order (increasing or decreasing) of enumeration. With this rule, the resource allocation graph can never have a cycle.

For example, provide a global numbering of all the resources, as shown

1 Card reader
2 Printer
3 Optical driver
5 Card punch

Now the rule is this: processes can request resources whenever they want to, but all requests must be made in numerical order. A process may request the first printer and then an HDD(order: 2, 4), but it may not request first an optical drive and then a printer (order: 3, 2). The problem with this strategy is that it may be impossible to find an ordering that satisfies everyone.


Leave a comment

Your email address will not be published. Required fields are marked *