Explain about deadlock prevention?
In order for the occurrence of deadlock, the four conditions like mutual exclusion, hold and wait, no pre-emption and circular wait must happen. By ensuring that one of these conditions cannot hold, we can stop the occurrence of deadlock.
Mutual exclusion
It must hold for non-sharable resources. For example a printer cannot be simultaneously shared by several processes. Sharable resources do not need mutually exclusive access, and therefore cannot be include in deadlock. Read-only files are a good example of a sharable resource.
Hold and wait
To ensure that hold and wait condition never happens in the system, we must guarantee that, whenever a process requests a resource, it does not hold any other resources. The protocols used are
1. Every process is to be request and be allocated all its resources before it begins execution.
2. Permits a process to request some resources only when the process has none (no other resources).