The GATE Grind

GATE 2016 CS – Question 61

Databases · Transactions and Concurrency Control · 2 marks · Multiple choice

Consider the following two phase locking protocol. Suppose a transaction $T$ accesses (for read or write operations), a certain set of objects $\{O_1, \ldots, O_k\}$. This is done in the following manner:

Step 1. $T$ acquires exclusive locks to $O_1, \ldots, O_k$ in increasing order of their addresses.

Step 2. The required operations are performed.

Step 3. All locks are released.

This protocol will

  1. guarantee serializability and deadlock-freedom
  2. guarantee neither serializability nor deadlock-freedom
  3. guarantee serializability but not deadlock-freedom
  4. guarantee deadlock-freedom but not serializability

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (A) guarantee serializability and deadlock-freedom

Explanation

Taking all locks before any are released and releasing them at the end is two phase locking, which guarantees serializability. Because every transaction asks for its locks in the same global order of addresses, no cycle of waiting transactions can form, so deadlock cannot happen.