Deadlock is a situation that involves the interaction of more than one resource and process with each other. We can visualize the occurrence of deadlock as a situation where there are two people on a staircase. One is ascending the staircase while the other is descending. The staircase is so narrow that it can only fit one person at a time. As a result, one has to retreat while the other moves on and uses the staircase. Once that person has finished, the other one can use that staircase. But here, neither person is willing to retreat and waits for the other to retreat. None of them are able to use the staircase. The people here are the processes, and the staircase is the resource. When a process requests for the resource that is been held by another process that needs another resource to continue, but is been held by the first process, then it is called a deadlock. There are four conditions necessary for the occurrence of a deadlock. They can be understood with the help of the above-illustrated example of a staircase:
Mutual Exclusion: When two people meet in the landings, they can’t just walk through because there is space only for one person. This condition allows only one person (or process) to use the step between them (or the resource) is the first condition necessary for the occurrence of the deadlock.
ALSO READ
Operating System Study materials
Operating System Technigoo Publication Book
Hold and Wait: When the two people refuse to retreat and hold their ground, it is called holding. This is the next necessary condition for deadlock.
No Preemption: For resolving the deadlock one can simply cancel one of the processes for the other to continue. But the Operating System doesn’t do so. It allocates the resources to the processors for as much time as is needed until the task is completed. Hence, there is no temporary reallocation of the resources. It is the third condition for deadlock.
Circular Wait: When the two people refuse to retreat and wait for each other to retreat so that they can complete their task, it is called circular wait. It is the last condition for a deadlock to occur.
Note: All four conditions are necessary for a deadlock to occur. If any single one is prevented or resolved, the deadlock is resolved.
Related Questions & Answers
- What are the Process States in Operating System?
- Write about Process Control Block.
- Write Various Operating System Services.
- What is the requirement to solve the Critical Section Problem?
- Write about the Priority Inversion Problem.
- Write various multithreading models.
- Discuss preemptive scheduling.
- Consider the following set of processes........
- Write about Semaphores. Explain its properties along with drawbacks.
- Write necessary conditions for arise of Deadlock.
- Define the following Terms: Mutual Exclusion, Thrashing, Thread
- Explain the features of Time sharing system.
- What is an operating system? Give the view of OS as a resource manager.
- Explain the following UNIX Commands: (a) grep (b) chmod (c) finger (d) cat (e) sort
- What is the thread? Explain thread Structure? And explain any one type of thread in detail.
- What is PCB? Discuss its major fields.
- List the four events that cause processes to be created. Explain each in brief.
- Explain the producer-consumer problem and its solution using the monitor.
- List Deadlock recovery techniques and explain any one of them.
- Write a short note in Critical Section.
- Explain context switching.
- Differentiate between Multi-Programming and Multi-Processing System.
- Write different types of system calls?
- What is a scheduler? Explain queuing diagram representation of process scheduler.
- Define the following Terms: Throughput, Waiting Time, Turnaround Time, Response Time.
- What is deadlock? List the conditions that lead to deadlock.
- Explain Banker’s algorithm for multiple resources with examples.
- What is Semaphore? Give the implementation of Bounded Buffer.
- What is Mutex? Write pseudocode to achieve mutual exclusion using Mutex.
- Explain the IPC problem. Explain the Dining Philosopher problem.