


This is a simple method available to track if any deadlock situation may arise. In a bulky system, deadlock prevention techniques may work well. Methods like "wait-for graph" are available but they are suitable for only those systems where transactions are lightweight having fewer instances of resource. Instead, deadlock avoidance mechanisms can be used to detect any deadlock situation in advance. Deadlock AvoidanceĪborting a transaction is not always a practical approach. In both the cases, the transaction that enters the system at a later stage is aborted. This scheme, allows the younger transaction to wait but when an older transaction requests an item held by a younger one, the older transaction forces the younger one to abort and release the item. If TS(T i) TS(T j), then T i is forced to wait until the resource is available. In this scheme, if a transaction requests to lock a resource (data item), which is already held with conflicting lock by some another transaction, one of the two possibilities may occur − This scheme allows the older transaction to wait but kills the younger one. T i is restarted later with a random delay but with the same timestamp. If TS(T i) TS(t j) − that is T i is younger than T j − then T i dies. In this scheme, if a transaction requests to lock a resource (data item), which is already held with a conflicting lock by another transaction, then one of the two possibilities may occur − There are deadlock prevention schemes that use timestamp ordering mechanism of transactions in order to predetermine a deadlock situation. If it finds that a deadlock situation might occur, then that transaction is never allowed to be executed. The DBMS inspects the operations and analyzes if they can create a deadlock situation. To prevent any deadlock situation in the system, the DBMS aggressively inspects all the operations, where transactions are about to execute. In case a system is stuck in a deadlock, the transactions involved in the deadlock are either rolled back or restarted. This situation is known as a deadlock.ĭeadlocks are not healthy for a system. In this situation, none of the processes can finish their task. Thus, all the processes wait for each other to release resources. T 2 is waiting for resource Z, which is held by T 0. Resource X is held by T 1, and T 1 is waiting for a resource Y, which is held by T 2. T 0 needs a resource X to complete its task. In a multi-process system, deadlock is an unwanted situation that arises in a shared resource environment, where a process indefinitely waits for a resource that is held by another process.įor example, assume a set of transactions.
