Q. Explain about Deadlock Avoidance?
To prevent deadlocks two kinds of techniques are used:
1) Static prevention: It employs P and V operators in addition to Semaphores to allocate and deallocate shared resources in multiprocessor. Semaphores are created based on sleep wait protocol. The portion of programme where a deadlock may occur is termed as critical section. Semaphores are like control signals used for avoiding collision between processes.
P and V technique of Deadlock prevention acquaintances a Boolean value 0 or 1 to every semaphore. Two atomic operators, P and V are used to access critical section symbolized by the semaphore. The P(s) operation makes value of semaphore is to be raised by one if s is already at non-zero value.
The V(s) operation raises value of s by one if it's not already one. The equation s=1 denotes availability of resource and s=0 denotes non-availability of resource.
At the time of execution different processes may submit their requests for resources asynchronously. The resources are assigned to different processors in such a manner that they don't create circular wait. The disadvantage of static prevention is poor resource utilisation.
2) One additional method of deadlock prevention is dynamic deadlock avoidance. It ensures deadlocks on runtime condition that may bring in heavy overhead in distinguishing potential existence of deadlocks.