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?
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? Correct Answer The database system is both deadlock-free and starvation-free.
Concept:
Wound – wait scheme means the newer transactions are killed when an older transaction make a request for a lock being held by newer transaction.
Explanation:
Here, Unique timestamps are assigned to each transaction using Lamport’s logical clock.
1) Now, first check if is it wound – wait scheme?
If TS(T2) < TS(T1) then
T1 is killed
else T2 waits.
This logic comes under wound – wait scheme, because it is given that T1 holds a lock on the resource R and T2 has requested a lock on same resource R. When T2 requests, T1 is killed because timestamp of T1 is larger than T2 means T1 is the newer transaction.
2) Now, wound – wait avoid starvation or not?
As newer transaction dies and restart with same timestamp and older one survives so after older transaction new will definitely execute. It means no possibility of starvation.
3) Deadlock free or not?
As, there is no starvation in this means no deadlock possibility.