Question

In a database system, unique timestamps are assigned to each transaction using Lamport's logical clock. Let TS(T1)\text{TS}(T_1) and TS(T2)\text{TS}(T_2) be the timestamps of transactions T1T_1 and T2T_2 respectively. Besides, T2T_2 holds a lock on the resource RR, and T1T_1 has requested a conflicting lock on the same resource RR. The following algorithm is used to prevent deadlocks in the database system assuming that a killed transaction is restarted with the same timestamp.

if TS(T1) < TS(T2) then
    T1 is killed
else
    T1 waits

Assume any transaction that is not killed terminates eventually. Which of the following is TRUE about the database system that uses the above algorithm to prevent deadlocks?

Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2017 answer key

Solution

Analyze the wait-for relationships and transaction restart mechanism under the given timestamp-based deadlock prevention algorithm.

The deadlock prevention algorithm specifies:
When transaction T1T_1 requests a lock held by T2T_2:

  • If TS(T1)<TS(T2)\text{TS}(T_1) < \text{TS}(T_2) (i.e., T1T_1 is older than T2T_2), T1T_1 is killed.
  • If TS(T1)≥TS(T2)\text{TS}(T_1) \ge \text{TS}(T_2) (i.e., T1T_1 is younger than T2T_2), T1T_1 waits.
  1. Deadlock Freedom:
    In this scheme, a transaction waits only if it is younger than the transaction holding the lock (TS(Twaiting)>TS(Tholding)\text{TS}(T_{\text{waiting}}) > \text{TS}(T_{\text{holding}})). Consequently, in the wait-for graph, all directed edges point from younger transactions to strictly older transactions. Because timestamps form a strict total order and strictly decrease along every path of waiting transactions, a directed cycle can never form in the wait-for graph. Therefore, the system is guaranteed to be deadlock-free.
  1. Starvation Freedom:
    When a transaction T1T_1 is killed, it is restarted with its original timestamp TS(T1)\text{TS}(T_1). As new transactions enter the system, they receive newer (larger) timestamps. Eventually, T1T_1's timestamp becomes smaller than that of other active transactions. An older transaction holding resources is never killed by younger transactions (younger transactions wait for it), so T1T_1 can acquire needed resources and proceed to completion without being indefinitely postponed. Therefore, the system is starvation-free.

Thus, the database system is both deadlock-free and starvation-free.

Final answer

A

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2017 Computer Science and Information Technology (CS) Session 1
Question
42 of 65, printed as CS Q.42
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.