Download presentation
Presentation is loading. Please wait.
Published byLesley Hopkins Modified over 8 years ago
1
Deadlock Operating Systems (CC2011NI) -Mr. Pranoy Man Pradhan
2
Deadlock Deadlock is the undesirable state of the system and is defined as the situation where a process or a set of processes are blocked waiting for some resource that his held by some other blocked processes. A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set.
3
Deadlocked processes wait for an event, which has to be triggered by other blocked processes, which never happens and hence processes are permanently blocked. Deadlock is defined as the permanent blockage of a set of processes that are competing for the resources or communicating with each other.
4
Example of Deadlock.
5
In above figure – Process P1 has acquired resource R1 and Process P2 has acquired resource R2 – Process P1 is waiting for resource R2 to be released by process P2 – Process P2 is waiting for resource R1 to be released by process P1; which never succeeds and hence processes are blocked.
6
Conditions for Deadlock Following four conditions must simultaneously hold for deadlock to occur – Mutual Exclusion. – Hold and Wait. – No Preemption. – Circular wait.
7
Conditions for Deadlock. Mutual Exclusion. – A resource can be used by only one process at a time. – If some process requests for a resource which is being held by another process, the requesting process is excluded or denied of the resource and has to wait until the resource has been released. Hold and wait. – A process may hold allocated resources while awaiting assignment of other resources.
8
Conditions of Deadlock No Preemption – A resource cannot be forcibly taken away from the process which is currently using the resource. The first three conditions are necessary but not sufficient for deadlock to occur. For a deadlock to actually take place, following fourth condition is required:
9
Conditions of Deadlock Circular Wait – A closed circular chain of processes exists such that each process holds at least one resource needed by the next process in the chain as shown in above figure.
10
Solution ? Four major areas of interest in deadlock research – Deadlock prevention. – Deadlock avoidance. – Deadlock detection. – Deadlock recovery.
11
Deadlock Prevention. – Use policies that will prevent the occurrences of deadlock. – Deadlock can be prevented from preventing any one of the four condition that is required for the occurrence of deadlock. – If any one of the condition can be prevented from holding, then deadlock will not occur.
12
Deadlock Avoidance. – Deadlock can be avoided by maintaining the system in safe state by careful allocation of system resources. – A system is said to be in safe state, if all pending processes can successfully be executed in some sequence satisfying all pending process requirements completely. – It is OS that checks whether the system will be in safe or unsafe state after the allocation of requested resources.
13
Deadlock Recovery. – Clears deadlocks from system so that deadlocked processes may complete their execution and free their resources. – Process termination : Abort one process at a time until the deadlock cycle is eliminated.
14
Deadlock detection. – Used in systems in which deadlocks can occur. – Determines if deadlock has occurred – Identifies those processes and resources involved in the deadlock. – Deadlock detection algorithms can incur significant runtime overhead.
15
Indefinite Postponement Also known as starvation. Typically occurs when a process is waiting in line for other processes (probably of higher priority). Processes with higher priority are allowed to get in front of the queue. Bypasses the waiting process. Determined by the scheduling algorithms. Preemption plays a big role.
16
Indefinite Postponement In a dynamic system, requests for resources happen all the time. Some policy is needed to make a decision about who gets which resource when. This policy, although seemingly reasonable, may lead to some processes never getting service even though they are not deadlocked. Can be as dangerous as deadlock.
17
Indefinite Postponement Possible solution : – ageing Eventually the waiting process's priority will exceed the priorities of all processes and it will be serviced. – FCFS resource allocation policy. the process waiting the longest gets served next.
18
Deadlock v/s Indefinite postponement Deadlock is more serious than Indefinite postponement. Deadlock: – all set of processes that are waiting for resources that never become available are affected. Indefinite postponement (starvation). – only a specific process is affected.
19
Self study Deadlock : Examples.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.