What is Deadlock? - Definition, Examples & Avoidance

An error occurred trying to load this video.

Try refreshing the page, or contact customer support.

Coming up next: Handling Starvation in Operating Systems: Origin & Solution

You're on a roll. Keep up the good work!

Take Quiz Watch Next Lesson
Your next lesson will play in 10 seconds
  • 0:04 What Is Deadlock?
  • 1:05 Prevention & Avoidance
  • 2:11 Detection
  • 2:49 Recovery
  • 3:32 Lesson Summary
Save Save Save

Want to watch this again later?

Log in or sign up to add this lesson to a Custom Course.

Log in or Sign up

Speed Speed

Recommended Lessons and Courses for You

Lesson Transcript
Instructor: Stephen Perkins

Stephen is a technology and electronics expert who has a passion for the work that he does.

A deadlock is a situation faced by current operating systems in order to deal with multiple processes. This lesson will help you understand the reasons why deadlock happens, its prevention methods, and how to recover from a deadlock situation.

What Is Deadlock?

There was a time where operating systems were only able to execute a single process at a time, thus giving full system resource and attention to that one single process. Nowadays operating systems can handle multiple tasks at once, but sometimes they have to deal with a problem known as a deadlock. A deadlock occurs when there is at least one process which is waiting for resources to be released by another process in order to finish a task correctly.

A deadlock graph showing two processes and two resources.

In this graph, Process A is waiting for Resource R2 to be released by Process B to finish a task. At the same time, Process B is waiting for Resource R1 to be released by Process A to finish a task. The technical term for what is happening here is known as starvation. Process B cannot begin until Process A finishes, which would then prevent the whole system from moving forward if deadlocked. This is something operating systems have to deal with, and many techniques can be implemented to stop or prevent a deadlock from occurring altogether.

Prevention & Avoidance

A deadlock can occur if and only if all the following conditions in a system are fulfilled simultaneously. These conditions are called the Coffman conditions:

  • Mutual exclusion states that each resource can be assigned to only one process at a time

  • Circular wait means that a process is holding a resource and requires more of the resources which are being held by other processes

  • Resource holding is when one or more processes can hold and wait for other resources to become available for use

  • No preemption means the resources that have already been granted access in advance and cannot be taken away at that time

If you are aware of these four conditions, then you can follow them and hopefully avoid a deadlock from occurring altogether. There can also be a slight variation in a deadlock situation in which there are two or more processes that are in a constantly changing state, which is known as a livelock. The critical difference here is that the processes at play have not actually stopped at all but have instead just become too busy to respond to each other.


Detecting a deadlock involves keeping track of both resource allocation and the requests that are currently pending from the processes. The best technique one can use in this situation involves creating a resource allocation graph, or RAG. This is an illustration that can be done to show what processes have the potential to become deadlocked, which creates an easy-to-follow visual for the user to understand. We usually do not know which resource will be needed when it comes to dealing with deadlock; thus there is a specific graph created for such a situation. By understanding how to use the RAG system, this allows for better deadlock prevention in the future.

To unlock this lesson you must be a Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use

Become a member and start learning now.
Become a Member  Back
What teachers are saying about
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create an account