-
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?
-
- The database system is both deadlock-free and starvation-free.
- The database system is deadlock-free, but not starvation-free.
- The database system is starvation-free, but not deadlock-free.
- The database system is neither deadlock-free nor starvation-free.
- The database system is both deadlock-free and starvation-free.
Correct Option: A
The given two transaction TS (T1) and TS (T2), in which T1 holds lock on resource R, T2 requires conflict lock on same resource R and T2 wait for graph.
If (TS(T2) < TS (T1)).
Then T1 killed.
(If restart with same TS value).
Else T2 waits.
This process shows avoids both deadlock and starvation because the transaction, who got killed will be starting with same time stamps and both are not waiting for each other.
Hence, option (a) is correct.