/    /  DBMS- Dead-Lock

Dead-Lock

 

In schedule-2, there are two transactions T3 and T4. They are partially executed one after the other (T31, T41, T32).

 

In the sub transaction T31 there are 4 instructions.

In the sub transaction T42 there are 3 transactions.

In the sub transaction T32 there is 1 transaction.

 

Here, T31 is holding an exclusive lock on B.

 T41 is holding a shared lock on A.

 T32 is holding an exclusive lock on A.

and T41 is waiting for T31 to unlock B.

 T32 is waiting for T41 to unlock A.

 

Therefore, we are at a state where neither of these transactions can ever proceed with its normal execution. This situation is called ‘DEAD LOCK’. 

 

When a deadlock occurs, the system should roll back one of the two transactions. Once a transaction is rolled back, then the data items that were locked by that transaction are unlocked.

To avoid this situation, one must require that each transaction in the system follow a set of rules, called a ‘locking protocol’.

 

Granting of Locks : 

  • Either exclusive or shared mode lock should be issued on data items of the transactions from time to time based on the requirement.
  • If the read operation is there, the ‘shared mode’ lock will be issued.
  • If the write operation is there, then ‘exclusive mode’ lock will be issued.

 

Reference Link

Dead-Lock