Skip to content
GATEiit

GATE CSE 2017 Session 1 Q52: Deadlock prevention: if TS(T2) < TS(T1) kill T1 else T2 waits

Syllabus topic: Transactions and concurrency control

Question

In a database system, unique timestamps are assigned to each transaction using Lamport's logical clock. Let TS(T1) and TS(T2) be the timestamps of transactions T1 and T2 respectively. Besides, T1 holds a lock on the resource R, and T2 has requested a conflicting lock on the same resource R. 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(T2)<TS(T1) then

T1 is killed

else T2 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?

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 2/3 mark in GATE.
Show answer and explanation

Answer: A (official GATE 2017 final answer key)

Concept used: This is the wound-wait scheme: an older requester wounds (kills) a younger holder, a younger requester waits; waits only go from younger to older, so no cycle, and a restarted transaction keeps its timestamp so it eventually becomes oldest.

Concept notes

Loading notes…

First step: Note which direction waiting is allowed (younger waits for older only) and ask whether a wait-for cycle can form; then ask what happens to a repeatedly killed transaction that keeps its old timestamp.

Full step-by-step solution

Loading…

Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.

More questions on Transactions and concurrency control

Every PYQ on this topic →

Share this question

WhatsAppDownload image

Source: official GATE 2017 Session 1 CS question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key