
In Deadlock Avoidance, the system will be checked if it is in a safe state or an unsafe state. Safe state is ensured when the request for the resource by the process is permitted when there is no deadlock found in the system. If there is deadlock found then the system will be in an unsafe state. To avoid deadlocks the process should inform the system that how many resources that a process should request for its execution. To make that happen we use Algorithm.
What is the use of deadlock avoidance?
In Deadlock Avoidance, the system will be checked if it is in a safe state or an unsafe state. Safe state is ensured when the request for the resource by the process is permitted when there is no deadlock found in the system. If there is deadlock found then the system will be in an unsafe state.
What is the difference between a safe state and deadlock?
A state is safe if the system can allocate resources to each process ( up to its maximum requirement) in some order and still avoid a deadlock. Formally, a system is in a safe state only, if there exists a safe sequence. So a safe state is not a deadlocked state and conversely a deadlocked state is an unsafe state.
What is a safe state and what is it used for?
What is a Safe State and what is its use in deadlock avoidance? When a process requests an available resource, system must decide if immediate allocation leaves the system in a safe state. System is in safe state if there exists a safe sequence of all processes.
What is safe state in operating system?
When a process requests an available resource, system must decide if immediate allocation leaves the system in a safe state. System is in safe state if there exists a safe sequence of all processes. Deadlock Avoidance: ensure that a system will never enter an unsafe state.

How does Deadlock Avoidance work?
In this method, the request for any resource will be granted only if the resulting state of the system doesn't cause any deadlock in the system. This method checks every step performed by the operating system. Any process continues its execution until the system is in a safe state. Once the system enters into an unsafe state, the operating system has to take a step back.
Why is the deadlock avoidance method used?
The deadlock Avoidance method is used by the operating system in order to check whether the system is in a safe state or in an unsafe state and in order to avoid the deadlocks, the process must need to tell the operating system about the maximum number of resources a process can request in order to complete its execution.
How many tapes can P2 have?
The system is no longer in a safe state. At this point, only process P2 can be allocated all its tapes. When it returns them the system will then have only 4 available tapes.Since P1 is allocated five tapes but has a maximum of ten so it may request 5 more tapes.
What is the key to deadlock avoidance?
The main key of the deadlock avoidance method is whenever the request is made for resources then the request must only be approved only in the case if the resulting state is a safe state.
What is an unsafe state?
In an Unsafe state, the operating system cannot prevent processes from requesting resources in such a way that any deadlock occurs. It is not necessary that all unsafe states are deadlocks; an unsafe state may lead to a deadlock. The above Figure shows the Safe, unsafe, and deadlocked state spaces.
What was the mistake in P3?
The mistake was granting the request from P3 for one more tape. If we made P3 wait until either of the other processes had finished and released its resources, then we could have avoided the deadlock
What happens when a process enters an unsafe state?
Any process continues its execution until the system is in a safe state. Once the system enters into an unsafe state, the operating system has to take a step back. With the help of a deadlock-avoidance algorithm, you can dynamically assess the resource-allocation state so that there can never be a circular-wait situation.
