Posted in Information Technology & Systems, Total Reads: 428
Deadlock is a very common situation is computer systems and databases. Generally in multi user system deadlock means a user is waiting for the resource which some other user is holding and the other user is waiting for the resource the first user is holding. So both are waiting for the other one to release the resource. Generally deadlock occurs in scenario where at least one of the resource is non-sharable.
Example: Suppose A puts a lock on table Employee to write something and B puts a lock on table department to write something. Now A is waiting for B to commit and release lock on department table and B is waiting for A to commit and release lock on employee table. Thus both ends up waiting for each other in a circular manner.
This can be easily explained by the following diagram:
In the above diagram User A is holding resource X and waiting for resource Y which is being held by User B. Also B is waiting for the resource X which is held by User A. Hence there is a deadlock.