⇰ DEADLOCK AVOIDANCE :-
As we know Deadlock-prevention algorithms only prevent deadlocks by limiting how requests can be made. The limits ensure that at least one of the necessary conditions for deadlock cannot occur. Side effects of deadlock prevention are low device utilization and reduced throughput. Avoidance of deadlock require additional information about how resources are to be requested.
For example, in a system with one tape drive and a printer, the system might need to know that process P will request first the tape drive and then the printer before releasing both resources, whereas process Q will request first the printer and then the tape drive. With this prior information of the complete sequence of requests and releases of resources the system can decide for each request whether or not the process should wait in order to avoid a possible future deadlock.
The simplest and most useful model requires that each process declare the maximum number of resources of each type that it may need. Given this a priori information, it is possible to construct an algorithm that ensures that the system will never enter a deadlocked state. A deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that a circular-wait condition can never exist.
If a system does not apply either a deadlock-prevention or a deadlock avoidance algorithm, then a deadlock situation may occur. In this environment the system may provide :-
∘ An algorithm that examines where a deadlock has occurred.
∘ An algorithm to recover from the deadlock.
Ofcourse, invoking the deadlock-detection algorith for every request will increase considerable overhead in computational time. A less expensive alternative is simply to invoke the algorithm at definite intervals.
⇰ RECOVERY FROM DEADLOCK :-
When a detection algorithm determines that a deadlock exists one possibility is to inform the operator that a deadlock has occurred and to let the operator deal with the deadlock manually. Another possibility is to let the system recover from the deadlock automatically.
There are two options for breaking a deadlock. One is simply to abort one or more processes to break the circular wait. The other is to preempt some resources from one or more of the deadlocked processes.
To eliminate deadlocks by aborting a process, we use any of two methods. In both methods, the system reclaims all resources allocated to the terminated processes.
• Abort all deadlocked processes. This method clearly will break the deadlock cycle, but at great expense.
• Abort one process at a time until the deadlock cycle is eliminated.
To eliminate deadlocks using resource preemption, we successively preempt some resources from processes and give these resources to other processes until the deadlock cycle is broken.
click here for discussion of deadlock and its characterization
Share, Follow and please comment if you find anything incorrect, or to share more information about the topic discussed above.
As we know Deadlock-prevention algorithms only prevent deadlocks by limiting how requests can be made. The limits ensure that at least one of the necessary conditions for deadlock cannot occur. Side effects of deadlock prevention are low device utilization and reduced throughput. Avoidance of deadlock require additional information about how resources are to be requested.
For example, in a system with one tape drive and a printer, the system might need to know that process P will request first the tape drive and then the printer before releasing both resources, whereas process Q will request first the printer and then the tape drive. With this prior information of the complete sequence of requests and releases of resources the system can decide for each request whether or not the process should wait in order to avoid a possible future deadlock.
The simplest and most useful model requires that each process declare the maximum number of resources of each type that it may need. Given this a priori information, it is possible to construct an algorithm that ensures that the system will never enter a deadlocked state. A deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that a circular-wait condition can never exist.
⇰ DEADLOCK DETECTION :-
If a system does not apply either a deadlock-prevention or a deadlock avoidance algorithm, then a deadlock situation may occur. In this environment the system may provide :-
∘ An algorithm that examines where a deadlock has occurred.
∘ An algorithm to recover from the deadlock.
To detect deadlock, the system needs to maiontain the 'wait-for' graph and priodically invoke an algorithm that searchs for a cycle in the graph.The deadlock exists in the system if and only if the 'wait-for'graph contains a cycle. Hence, for detecting deadlock the algorithm searches for a cycle in the graph.
Wait-For Graph |
If deadlock occurs frequently, then the detection algorithm should also be invoked frequently. We can invoke the deadlock detection algorithm every time a request for allocation cannot be granted immediately. By this we can identify not only the deadlocked set of processes but also the specific process that cause the deadlock.
⇰ RECOVERY FROM DEADLOCK :-
There are two options for breaking a deadlock. One is simply to abort one or more processes to break the circular wait. The other is to preempt some resources from one or more of the deadlocked processes.
To eliminate deadlocks by aborting a process, we use any of two methods. In both methods, the system reclaims all resources allocated to the terminated processes.
• Abort all deadlocked processes. This method clearly will break the deadlock cycle, but at great expense.
• Abort one process at a time until the deadlock cycle is eliminated.
To eliminate deadlocks using resource preemption, we successively preempt some resources from processes and give these resources to other processes until the deadlock cycle is broken.
click here for discussion of deadlock and its characterization
Share, Follow and please comment if you find anything incorrect, or to share more information about the topic discussed above.
Very good ……. We are getting a lot of help…. Like this, make it further on the new topic...Really helpful ...keep it up
ReplyDelete