give the difinition of deadlock prevention and deadlock avoidance. describe the similarity and different of them.
Definitions and similarities :
Deadlock Prevention
We can prevent Deadlock by eliminating any of the above four conditions.
They are :
Eliminate Mutual Exclusion
It is not possible to dis-satisfy the mutual exclusion because some
resources, such as the tap drive and printer, are inherently
non-shareable.
Eliminate Hold and wait
Eliminate No Preemption
Preempt resources from the process when resources required by other
high priority processes.
Eliminate Circular Wait
Each resource will be assigned with a numerical number. A process
can request the resources only in increasing order of
numbering.
Deadlock avoidance
In deadlock avoidance, the request for any resource will be granted if the resulting state of the system doesn't cause deadlock in the system. The state of the system will continuously be checked for safe and unsafe states.
In order to avoid deadlocks, the process must tell OS, the maximum number of resources a process can request to complete its execution.
The simplest and most useful approach states that the process should declare the maximum number of resources of each type it may ever need. The Deadlock avoidance algorithm examines the resource allocations so that there can never be a circular wait condition.
DIFFERENCES:
Prevention:
• The goal is to ensure that at least one of the necessary conditions for deadlock can never hold.
• Deadlock prevention is often impossible to implement.
• The system doesnot require additional apriori information regarding the overall potential use of each resource for each process.
• In order for the system to prevent the deadlock condition it does not need to know all the details of all resources in existence, available and requested.
• Deadlock prevention techniques include non-blocking synchronization algorithms, serializing tokens, Dijkstras algorithm etc.
• Resource allocation strategy for deadlock prevention is conservative, it under commits the resources.
• All resources are requested at once.
• In some cases preempts more than often necessary.
Avoidance:
• The goal for deadlock avoidance is to the system must not enter an unsafe state.
• Deadlock avoidance is often impossible to implement.
• The system requires additional apriori information regarding the overall potential use of each resource for each process.
• In order for the system to be able to figure out whether the next state will be safe or unsafe, it must know in advance at any time the number and type of all resources in existence, available, and requested.
• Deadlock avoidance techniques include Banker’s algorithm, Wait/Die, Wound/Wait etc.
• Resource allocation strategy for deadlock avoidance selects midway between that of detection and prevention.
• Needs to be manipulated until atleast one safe path is found.
• There is no preemption.
give the difinition of deadlock prevention and deadlock avoidance. describe the similarity and different of them.