Deadlock prevention means to prevent at least one of the necessary conditions from occurring. The methods to prevent the individual conditions are discussed below:
Mutual exclusion can not be prevented since it is the intrinsic property of the resource. E.g. printer is non sharable.
Hold and wait can be prevented by ensuring that whenever a process request a resource, it must not be holding any resource. There are two ways of doing it:
No preemption can be prevented by implementing resource preemption. If the requested resources can not be allocated then the resources that are currently held by the process are preempted. It is different from hold and wait where the currently held resources are release first and then a request for all resources is made again.
This can be applied to resources like CPU registers and memory space but not to printers and tape drives.
Circular wait can be prevented by ensuring that the process can request for resources in some order only.
E.g. Suppose each process is numbered like P0, P1, p2,. .., Pn. Then they can request for resources held by higher numbered process only i.e. P0 can request from P1, P2 and so on, p1 from P2, P3 and so on but not P0, P2 from P3, P4 and so on but not P0 and P1.
The above discussion on deadlock prevention is summarized in the form of a PPT with animations below.
Note: Click within the slide area for animations. Clicking on the “next” slide button will not display any animation
Previous Next Deadlock Deadlock Avoidance