Definition: Deadlock in OS
In the operating system, multiple resources are used by process in three different ways, such as –
- Fire requests for resource
- Use this resource
- Free this resource after completing task
Definition – Deadlock is a condition that is created in operation system when one process is holding some resources for making their execution but same resources are hold by another process, then this condition is known as “Deadlock“. Mostly, deadlock problem is arisen in multi processing system because in which multiple processes try to share particular mutually exclusive resource.
Click Here – Complete Study to Operating system Tutorial
Why does Arise Deadlock?
Deadlock problem can arise, if four Coffman Conditions are occurred simultaneously in operating system such as –
Mutual Exclusion
In the Mutual Exclusion, one resource is assigned by single process at same time; if other process is needed to same allotted resources then it has to required wait to occupy for those resources. So, Mutual Exclusion can’t be broken 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 is held by second process, and this process is again waiting for such resource which are held by third process and so on. Then we can say that Circular wait’s condition is occurred.
Deadlock Handling Techniques
There are five different deadlock handling methods, and with using them deadlock problems can be avoided 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.
Click Here – Deadlock Prevention Algorithms in Operating System
Deadlock Avoidance
Deadlock avoidance technique helps to avoid deadlock to occur in the system. Deadlock avoidance is the mostly used by several types of operating systems, but it is used mainly 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 occurred 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 are happened in the system, and we ignore them. If, any time deadlock is occurred during the execution of any instructions then system is required to restart the entire system, same time our data will be lost.
Some operating system such as Windows, UNIX, and Linux are 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 is assumed that it will not come again this problem. This technique is implemented because some time the cost of deadlock handling is more expensive compare to simple ignoring them. If, some time deadlock is happened by chance then entire system will be rebooted.
Deadlock Example in OS
Road Traffic is an real life example of deadlock. Explain here –
- If traffic is flowing in one side.
- And, bridge is worked as resource.
- When deadlock arises, then this problem can be solved, if one car is getting backs up (Preempt resources and rollback).
- Deadlock issue is happened, 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.
Deadlock is capable to contain the starvation.
Deadlock is occurred when anyone condition is happened 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 are executed. Then Starvation is occurred.
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 is happened.
Related Posts
- Demand Paging in OS (Operating System): Example,…
- Mainframe Computer: Definition, Example, Types,…
- Multiprogramming Operating System: Examples, Types,…
- Unix OS (Operating System): Examples, Types, and Functions!!
- How to Change Background and Wallpaper on Mac? Using…
- How to Screen Record with Internal Audio on Mac?…
- How to Create Folder on Mac? Using 5 Simple Methods!!
- How to Change Folder Colors on Mac? Using 2 Simple Methods!!
- How to Password Protect Folder in Mac? Using 3…
- How to Edit a PDF on Mac for Free? Easier 8 Methods!!
- How to Show Hidden Files on Mac and Macbook? 9…
- How to Hide Files and Folder on Mac? You Can Use 10…