What Is Deadlock in Os and Its Conditions

For example, a computer has three USB flash drives and three processes. Each of the three processes can contain one of the USB drives. Thus, if each process requires a different drive, all three processes have the crashing situation because each process is waiting for the release of the currently used USB drive. The result is a circular chain. In an operating system, a crash occurs when a process or thread enters a standby state because a requested system resource is held by another wait process, which in turn waits for another resource held by another wait process. If a process cannot change its state indefinitely because the resources it requests are being used by another waiting process, the system is locked. [3] This approach assumes that there will never be a dead end. It is also an application of the ostrich algorithm. [10] [11] This approach was originally used by MINIX and UNIX. [7] This is used when the time intervals between the appearance of blockages are large and the data loss that occurs each time is tolerable.

Although these conditions are sufficient to create a block for resource systems with a single instance, they only indicate the possibility of a crash on systems with multiple resource instances. [8] A livelock is similar to a deadlock, except that the states of the processes involved in the livelock are constantly changing relative to each other and none are progressing. In the figure above, the process has T0 resource1, it needs resource2 to complete its execution. Similarly, the T1 process has resource2 and must also acquire resource1 to complete its execution. In this way, T0 and T1 are at an impasse because each of them needs the resources of the others to complete its execution, but none of them is ready to give up its resources. Deadlock conditions can be avoided using a number of methods. Let`s take a look at some of the methods. Most current operating systems cannot prevent crashes. [9] When a crash occurs, different operating systems respond to it in different non-standard ways. Most approaches work by preventing one of the four Coffman conditions from occurring, especially the fourth.

[10] The main approaches are as follows. As we discussed in the section above, the four conditions: mutual exclusion, maintenance and waiting, no pre-emption and circular waiting when maintained by a system lead to a dead end. The main objective of the stalemate prevention method is to violate one of the four conditions; Because if one is violated by a condition, the problem of deadlock will never happen. Since the idea behind this method is simple, the difficulty can arise when physically implementing this method in the system. The appearance of a blockage can be detected by the resource scheduler. Distributed blocks can occur in distributed systems when using distributed transactions or concurrency control. It is better to avoid an impasse than to take action after the impasse has occurred. This requires additional information, such as . B how resources are to be used. Block avoidance is the simplest and most useful model, where each process declares the maximum number of resources of each type it may need. It is better to avoid a blockage than to take action after the blockade.

Waiting for a chart can be used to avoid crashes. However, this is only useful for smaller databases, as it can become quite complex in larger databases. The second option is to go back, as the operating system records the state of the process and can easily restore a process to its previous state, which can easily eliminate the crashing situation. Once a blockage is detected, it can be fixed using one of the following methods:[citation needed] Let`s take a concrete example to better understand the concept of deadlock. Let`s say you study at a school and you also use the bus service. So you have to pay two fees, namely bus fees and tuition fees. Now imagine a situation where you deposit the bus fees and the accountant says you have to submit the tuition first and then the bus fee. So you`re going to submit the tuition to the other counter and the accountant there said that you have to submit the bus fee first and then the tuition. So what are you going to do here? You are at an impasse here. Not sure what to submit first, bus fees or tuition? Read our blog What are the techniques for managing crashes in the operating system? to find ways to deal with the impasse when it occurs.

Distributed blocks can be detected either by creating a global wait graph from local wait diagrams to a block detector, or by a distributed algorithm such as edge hunting. A crash situation for a resource can only occur if all of the following conditions occur simultaneously in a system:[5] For example, if a process releases an R1 resource and issues a request for R2 and the first message is lost or delayed, a coordinator (block detector) could incorrectly terminate a crash (if requesting R2 with R1 would cause a crash). 3) Completely ignore the problem: If the deadlock is very rare, let it pass and restart the system. This is the approach taken by Windows and UNIX. We can think of the appearance of Deadlock as a situation where there are two people on a staircase. One goes up the stairs while the other goes down. The staircase is so narrow that it can only accommodate one person at a time. As a result, one has to retreat while the other moves and uses the stairs. Once this person is done, the other can use this staircase. But here, neither of the people is ready to withdraw and wait for the other to withdraw. None of them are able to use the stairs. People here are the process and stairs are the resource.

A crash occurs in the operating system when two or more processes need a resource owned by the other process to complete their execution. The methods used to handle the problem of crashes are as follows: A crash occurs when all four Coffman conditions are true. However, these conditions are not mutually exclusive. .