Deadlock in Operating System (OS)

Operating System Deadlock

A deadlock is a situation in an operating system where two or more processes are unable to proceed because each is waiting for one of the others to do something. This can occur when multiple processes request and are allocated resources in a way that results in a cycle of dependencies, such that none of the processes can proceed. Deadlock in Operating System can be prevented or resolved by using techniques such as resource allocation algorithms, deadlock detection, and recovery schemes.

Process scheduling in Operating System (OS)

Deadlock in Operating System

Deadlock refers to the condition when 2 or more processes are waiting for each other to release a resource indefinitely. A process in nature requests a resource first and uses it and finally releases it.

But in deadlock situation, both the processes wait for the other process. Let’s look at one example to understand it – Say, Process A has resource R1 , Process B has resource R2. If Process A request resource R2 and Process B requests resource R1, at the same time , then deadlock occurs.

Important Features of Deadlock –

  • In deadlock, processes get blocked because each process is holding some resource and they are waiting for other resource , which is held by another process.
  • Deadlock usually occurs in multiprocessing, time- sharing etc
  • In Multiprocessing, many processes share a specific type of mutually exclusion resource known as soft lock.
  • Time Sharing computers are equipped with a hardwired lock which gaurantees exclusive access  to processes , thus preventing deadlock.
  • There is no general solution to avoid soft deadlock.
Deadlock in Operating System-1

Conditions for Deadlock

Deadlock can occur if all the given 4 conditions ( Coffman Conditions ) are satisfied, that is if all are true  :

  • Mutual Exclusion
  • Hold and Wait
  • No Preemption
  • Circular wait

Some important features of deadlock include:

  1. Mutual exclusion: Resources are held in a non-shareable mode, meaning that only one process can use a resource at a time.

  2. Hold and wait: A process is holding at least one resource and waiting for additional resources that are currently being held by other processes.

  3. No preemption: Resources cannot be taken away from a process once they have been acquired.

  4. Circular wait: Two or more processes are waiting for each other to release resources, resulting in a cycle of waiting.

  5. Deadlock can occur in a variety of computing environments, including distributed systems, databases, and operating systems.

  6. Deadlock can be resolved through various methods such as prevention, detection, and recovery.

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription