Explain 2 phase locking technique in brief.

This answer is restricted. Please login to view the answer of this question.

Login Now

A lock is a variable associated with a data item that describes the item’s status with respect to possible operations that can be applied to it. Generally, there is one lock for each data item in the database.

Locking is an operation with secures: permission to read or write a data item. Two-phase locking is a process used to gain ownership of shared resources without creating the possibility of deadlock. The 3 activities taking place in the two-phase update algorithm are:

  • Lock acquisition
  • Modification of data
  • Release lock

Two-phase locking prevents deadlock from occurring in distributed systems by releasing all the resources it has acquired if it is not possible to acquire all the resources required without waiting for another process to finish using a lock. A transaction in the two-phase locking protocol can be assumed one of the two phases:

  1. Growing Phase: In this phase, a transaction can only acquire locks but cannot release any lock. The point when a transition acquires all the locks it needs is called the lock point.
  2. Shrinking Phase: In this phase, a transaction can only release locks but cannot acquire any.
If you found any type of error on the answer then please mention on the comment or report an answer or submit your new answer.
Leave your Answer:

Click here to submit your answer.

  Loading . . .