GATE CS 2024 Set 2 — Question 27

MSQ+1 / -0MediumTwo-Phase LockingTransactions & ConcurrencyDatabases

Databases → Transactions & Concurrency → Two-Phase Locking

Last updated

Question

Which of the following statements about the Two Phase Locking (2PL) protocol is/are TRUE?
A.
2PL permits only serializable schedules
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
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
D.
A deadlock is possible with 2PL

Correct answer

(A) 2PL permits only serializable schedules; (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; (D) A deadlock is possible with 2PL

Solution

(A) TRUE: The Two Phase Locking (2PL) protocol guarantees conflict serializability. Any schedule allowed by 2PL is serializable.
(B) FALSE: This statement describes a locking strategy that does not follow the two-phase rule. In 2PL, a transaction must acquire all necessary locks (Growing Phase) before it releases any lock. It cannot release a lock "just after the operation" if it intends to acquire more locks later.
(C) TRUE: This is the definition of the Shrinking Phase in 2PL. Once a transaction releases a lock, it enters the shrinking phase and cannot acquire any new locks.
(D) TRUE: 2PL does not prevent deadlocks. Transactions can wait for each other in a cycle (e.g., T1 holds A and waits for B, T2 holds B and waits for A) while adhering to 2PL rules.

More questions on Transactions & Concurrency

Practice GATE CS PYQs with adaptive difficulty

Timed practice, skill tracking, and AI explanations — free to start.

Start practicing free