GATE CS 2024 Set 2 | Question 27

MSQ · 1 mark

Which of the following statements about the Two Phase Locking (2PL) protocol is/are TRUE?

  1. Option A: 2PL permits only serializable schedules (correct)
  2. Option B: With 2PL, a transaction always locks the data item being read or written just before every operation and always releases the lock just after the operation
  3. Option C: With 2PL, once a lock is released on any data item inside a transaction, no more locks on any data item can be obtained inside that transaction (correct)
  4. Option D: A deadlock is possible with 2PL (correct)

Answer

(A), (C), (D)

Explanation

Under 2PL each transaction has a growing phase, in which it may only acquire locks, followed by a shrinking phase, in which it may only release them.

  • A is true. Every schedule that 2PL allows is conflict serializable, equivalent to running the transactions one after another in the order of their lock points.
  • B is false. Releasing a lock right after each operation and then locking the next item mixes the two phases, which is exactly what 2PL forbids.
  • C is true. This is the shrinking phase: after the first release, no new lock may be taken.
  • D is true. If T1 holds a lock on X and waits for Y while T2 holds Y and waits for X, both wait forever; basic 2PL does nothing to prevent this.

Answer: A, C, D