Indira Das - 54
Indira Das - 54
Deadlock Characteristics
The deadlock has the following characteristics:
• Mutual Exclusion
• No Preemption
• Circular Wait
Deadlock Prevention
We can prevent a Deadlock by eliminating any of the above four conditions.
• Eliminate Hold and Wait: Allocate all required resources to the process
before the start of its execution, this way hold and wait condition is
eliminated but it will lead to low device utilization. for example, if a process
requires a printer at a later time and we have allocated a printer before the
start of its execution printer will remain blocked till it has completed its
execution. The process will make a new request for resources after
releasing the current set of resources. This solution may lead to starvation.
Deadlock Avoidance
A deadlock avoidance policy grants a resource request only if it can
establish that granting the request cannot lead to a deadlock either immediately
or in the future. The kernal lacks detailed knowledge about future behavior of
processes, so it cannot accurately predict deadlocks.
Banker’s Algorithm
Bankers’s Algorithm is a resource allocation and deadlock avoidance
algorithm which test all the request made by processes for resources, it checks for
the safe state, and after granting a request system remains in the safe state it
allows the request, and if there is no safe state it doesn’t allow the request made
by the process.
• If the request made by the process is less than equal to the max needed for
that process.
• If the request made by the process is less than equal to the freely available
resource in the system.
ABCD
6576
ABCD
3112
ABCD
P1 1 2 2 1
P2 1 0 3 3
P3 1 2 1 0
ABCD
P1 3 3 2 2
P2 1 2 3 4
P3 1 3 5 0
ABCD
P1 2 1 0 1
P2 0 2 0 1
P3 0 1 4 0
Conclusion
Operating Systems employ deadlock avoidance to prevent deadlock by
using the Banker’s algorithm or the resource allocation graph. Deadlock
avoidance works by informing the operating system of the resources needed by
the process to finish execution, and the operating system then determines
whether or not the requirements can be met.
The System is said to be in a Safe state if all the resources required by the
Process are satisfied with the resources that are currently available. The System is
said to be in an unsafe state if all of the resource requirements of the Process
cannot be met by the available resources in any way. Deadlock prevention is more
strict than Deadlock Avoidance.