Deadlock in OS with Handling Methods & Examples

Deadlock is a condition that created in operation system when one process is holding some resources for making their execution; but same resources hold by another process, then this condition has name the “Deadlock“.

Mostly, deadlock problem get arise in multi processing system because in which multiple processes try to share particular mutually exclusive resource.

In operating system, multiple resources are used by process in three different ways, such as:

Free this resource after completing task

Fire requests for resource

Use this resource

Why does Arise Deadlock?

Deadlock Problem can arise, if four Coffman Conditions occurr simultaneously in operating system such as:

Mutual Exclusion

In the Mutual Exclusion, one resource assigned by single process at same time; if other process have to need to same allotted resources, then it has to required wait to occupy for those resources.

So, Mutual Exclusion can’t breake for process because in practically, single resource can conduct the task of one process at once. For instance – Multiple users can’t fire commands to print document at same time.

Hold and Wait

This condition is occurred, if one process holds few resources. And, it has to wait for further resources which are already held by another waiting process.

No Preemption

In which one process cannot take the resources of other processes by force. But if we find some resources that are causing a system deadlock, then we can stop that resource from holding that resource.

Circular Wait

If, first process is waiting for such resource that held by second process, and this process is again waiting for such resource which held by third process and so on. Then we can say that Circular wait’s condition get occure.

For More Visit - Computer Tech Info

Deadlock Handling Techniques

There are five different deadlock handling methods, and with using them deadlock problems can be avoiding in operating system. Here, explain each one –

Deadlock Prevention

It is very necessary to prevent deadlock in operating system before it can happen. So, system identify every transaction before getting its execution, and ensures it doesn’t get to deadlock problem. If, that time any transaction may occur deadlock issue, then it can’t get to execute its instructions.

Deadlock Avoidance

Deadlock avoidance technique helps to avoid deadlock to occur in the system. This deadlock avoidance is the mostly using by several types of operating systems. But, mainly it is going to use for end users. This concept is more comfortable for single user system; because they use their system for simply browsing as well as other simple activities.

Deadlock Detection and Recovery

In this technique, CPU has ability to guess few criteria, if deadlock will be occurring in the entire system. Then, CPU will precede few recovery techniques to resolve the deadlock problem, and CPU frequently identify to all deadlock issues. CPU applies the Resource Allocation Graphs concept to detect the deadlock in the entire system.

In recovery scenario, CPU gets forcefully resources assigned to few processes, and those resources can also supply to another process, but that process must be high level priority.

Deadlock Ignorance

In the deadlock ignorance technique, CPU always alerts to identify for various deadlock that happened in the system, and we ignore them. If, any time deadlock get occur during the execution of any instructions then system requires to restart the entire system, same time our data will get lost.

Some operating system such as Windows, UNIX, and Linux designed to deliver best performance. But, their performance is getting to degrade while using deadlock handling techniques.

Ostrich Algorithm

In the Ostrich Algorithm, we will simply ignore deadlock problems, and it assumes that it will not come again this problem. This technique gets implement; because some time the cost of deadlock handling is more expensive compare to simple ignoring them. If, some time deadlock happened by chance then entire system will be rebooting.

Deadlock Example in OS

Road Traffic is an real life example of deadlock. Explain here:

  • If traffic is flowing in one side.
  • And, bridge works as resource.
  • When deadlock arises, then this problem can solve, if one car is getting backs up (Preempt resources and rollback).
  • Deadlock issue get happen, if multiple cars are getting to backed up.
  • So, now starvation is easily getting on.

Difference Between Deadlock and Starvation

Here, few difference in between the Deadlock and Starvation in operating system

DEADLOCK

If anyone process is getting block, then we can say that deadlock is happening.

Deadlock works as a infinite process, because it is not capable to long wait process.

This is capable to contain the starvation.

Deadlock is going to occur when anyone condition get happen in the among of these Coffman Conditions (Mutual exclusion, hold and wait, preemption and circular wait).

STARVATION

Low priority processes are getting block, but high priority processes execute. Then Starvation get occur.

Starvation does not work as infinite process, but it can be long waiting process.

But all starvation does not need to have deadlock.

If, priority and resource management is getting the uncontrollable then, Starvation happens.

Comments

Popular posts from this blog

What are the main Advantages and Limitations of using a Mainframe Computer?

Computer Network Basics: Goals, Features, and Applications

Comprehensive Guide to Web Servers: Features, Pros, Cons, and Key Characteristics