⇰ DEADLOCK :-
As we know in a multiprogramming environment several processes may compete for a finite number of resources. If a process requests resources and if the resources are not available at that time, the process enters a state called waiting state. Sometimes, a waiting process is never again able to change state or never out from waiting state, because the resources it has requested are held by or taken by other waiting processes before this process.This situation is called a Deadlock.
⇰ DEADLOCK CHARACTERIZATION:-
In a deadlock processes never finish executing and system resources are tied up and also preventing other jobs from starting. Here are some features that characterize deadlocks. A deadlock situation can arrive if the following four conditions hold simultaneously in any operating system :-
1. Mutual exclusion :- A process must hold at least one resource in a nonsharable mode so that only one process can use the resource at a time. If another process requests that resource, the requesting process must be delayed until the resource has been released.
2. Hold and wait :- A process must be holding at least one resource and waiting to acquire additional resources that are currently being held by other processes.
3. No preemption :- Resources cannot be preempted means a resource can be released only voluntarily (when procss want) by the process holding it, after that process has completed its task.
4. Circular wait :- For this condition a set {P0, P1, ..., Pn} of waiting processes must exist such that P0 is waiting for a resource held by P1, P1 is waiting for a resource held by P2, ..., Pn−1 is waiting for a resource held by Pn, and Pn is waiting for a resource held by P0 ,making a circular chain of waiting processes.
4. Circular wait :- For this condition a set {P0, P1, ..., Pn} of waiting processes must exist such that P0 is waiting for a resource held by P1, P1 is waiting for a resource held by P2, ..., Pn−1 is waiting for a resource held by Pn, and Pn is waiting for a resource held by P0 ,making a circular chain of waiting processes.
⇒ To ensure that deadlocks never occur, the system can use either a deadlock prevention or a deadlock-avoidance scheme. Deadlock prevention provides a set of methods to ensure that at least one of the necessary conditions cannot hold. Deadlock avoidance requires that the operating system be given additional information in advance concerning which resources a process will request
and use during its lifetime.
⇰ DEADLOCK PREVENTION :-
As we know for deadlock to occur, each of the four necessary conditions must hold.We can prevent the occurance of deadlock by ensuring that at least one of these conditions cannot hold. Let us examine of the four necessary conditions separately :-
→ Mutual Exclusion :- For deadlock to occur mutual exclusion condiyion must hold means atlest one resource must be in non- sharable.Sharable resources do not require mutually exclusive access and thus cannot be involved in a deadlock. Read-only files are a good example of a sharable resource. In general we cannot prevent deadlocks by denying the mutual-exclusion condition, because some resources are intrinsically nonsharable.
→ Hold and wait :- To ensure that hold & wait condition never occurs in the system, we must guarantee that, whenever a process request a resource, it does not hold any other resources. One protocal that we can use require each process to request and bew allocated all its resources before it begins execution.
An alternate protocol allows a process to request resources only when it has non.A process may request some resources and use them. Before it can request any additional resources, it must release all the resouces that it is currently allocated.
→ No preemption :- This is the third condition for deadlkock to occur , says no preemption of resources that have already been allocated. To mensure that this condition does not hold, we can use some protocole. As if a process is holding some resources and request another resource that cannot be immediatly allocated to it, then all resources from this process are preempted. The preempted resources are added to the list of resources. The process will be restarted only when it can regain its old resources as well as the new once that it was requesting.
→ Circular wait :- This is the forth and final condition for deadlock to occur. One way to ensure that this condition never holds is to impose a total ordering of all resource types and to require that each process requests resources in an increasing order of enumeration.
Share, Follow and please comment if you find anything incorrect, or to share more information about the topic discussed above.
Short and simple!!!! Excellent Bro
ReplyDeleteDbms ka kuchh daal n buro
ReplyDeleteI am preparing for that. You will got posts soon on that topics.
Delete