In multiprogramming environment, several processes compete to acquire some limited number of resources. When a process request resource and if it will not get the resource, it will enter into waiting state. Sometimes, the waiting process is never again able to change state, because the resources it has requested are held by other waiting processes. This situation is called a deadlock in operating system.
It is the responsibility of programmer to avoid the situation of deadlock.
A deadlock situation can arise if the following four conditions hold simultaneously in a system:
All four conditions must hold for a deadlock to occur.
We can deal with the deadlock problem in one of three ways:
To ensure that deadlock never occurs in the operating system, it can use either a deadlock-prevention or deadlock-avoidance scheme.
Deadlock prevention provides a set of methods for ensuring that at least one of the necessary conditions cannot hold. These methods prevent deadlocks by constraining how requests for resources can be made.
Deadlock avoidance requires that the operating system be given in advance additional information concerning which resources a process will request and use during its lifetime. With this additional knowledge, it can decide for each request whether or not the process should wait.
When a detection algorithm determines that a deadlock exists, several alternatives are available. One possibility is to inform the operator that a deadlock has occurred and to let the operator deal with the deadlock manually. There are two options for breaking a deadlock.
Download as PDF
Read next: Memory Management ››
« Back to Course page
Punjab Civil Services 2021