As mentioned earlier in the previous post, there are several methods that can be used when it comes to the handling of deadlock, such as the prevention, detect and resolve and the ignore method. We want to focus more on the prevention method for deadlock. There are a few methods the operating system can use to prevent deadlocks, since deadlocks occur as a result of one of 4 main criteria, we just need to prevent one of these from happening.
- Mutual exclusion. This means not more than one program is allowed to enter critical section, basically this prevents simultaneous access to a shared resource.
- Hold and wait: This means an object or process holds on to a resource while waiting for another, there by depriving other process of these resource.
- No preemption: This simply means once a process request for a resource is granted it cannot be taken away from it and given to another process unless it gives it up.
- Circular wait : This refers to a situation in which a process is waiting for a resource that happens to be with another process, and the next process is also waiting for a resource from another process in succession, this is circular wait and can lead to deadlock.