Introduction to Deadlock


Deadlock is a very important topic from operating systems to all the students who are preparing for university exams, entrance exams or interview preparation. Theory based question ,numeric based question are asked from this topic. but trust me guys it is one of the simplest topics in operating system for those who understood the basics of deadlock. So,let's start, shall we?

What is Deadlock?
Let me give you an example so that you can get an idea of what deadlock is. Suppose you are in a party and you want to drink soup. So you went to soup counter and you took a bowl but unfortunately there was no spoon left. One of you friend is also interested in drinking soup and he has a spoon but no bowl. So, you asked him to give you the spoon so that you can drink soup but you friend says you give him the bowl so that he can drink the soup.
So deadlock is similar to the above mentioned example because you want a resource to fulfill your task but that resource is with some other person and the other person wants to perform a task but his resource is with you.

In multiprogramming system a number of process compete for limited number of resources and if a resource is not available then that process goes in waiting state. Now if a process is unable to change its waiting state indefinitely because the resource requested by it is held by some other process then the system is said to be in deadlock.


Introduction to Deadlock

Now look at the example above which demonstrates deadlock. The above picture represents a resource allocation graph which we will discuss later on. But for now you just remember that circle represents process, rectangle represents a resource and arrow represents a request.
In the above picture Process 1 has acquired resource 1 but it has requested for resource 2 and similarly Process 2 has acquired resource 1 but it has requested for resource 1. So, both the process wants a resource which is acquired by the other. So, this forms a deadlock.

System Model

Every process follows the system model so let's look what a system model actually is.
System model is a three step process in which :-

  1. Every process will request fro a resource.
  2. If available then the process is allocated that resource.
  3. Process must release the resource after using it.
So this was the basic introduction about deadlock I hope you understood it. In the next post I will discuss about the conditions due to which deadlock occurs.
Post a Comment (0)
Previous Post Next Post