821 views
2 votes
2 votes

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

  1. The database system is both deadlock-free and starvation-free.
  2. The database system is deadlock-free, but not starvation-free.
  3. The database system is starvation-free, but not deadlock-free.
  4. The database system is neither deadlock-free nor starvation-free.

What i tink

if T1  its not restarted with the same timestamp .... and its given a new timestamp and that will definetely be higher than TS(T2)

which is still making TS(T1) younger...now when T2 is done..T1 executes ...

So if the TS(T1) is restarted with same timestamp or different is actually not making a difference

but it is discussed that if T1 starts again with new timestamp then there would be starvation..how??

1 Answer

Best answer
0 votes
0 votes
We can assume that there are N transaction ( T1,T2,T3...Tn) in execution.Every transaction has been given assigned a  Timestamp. Suppose currently the timestamp order is TS(T2)<TS(T1)<TS(T3)<...  . Now T1 is killed using above algorithm and it is assigned a new timestamp (which will be greater than all previous because timestamp is given in increasing order). since T1 is younger than all the other transaction it will have to wait for other Transaction to complete.

Hence starvation will occur.
selected by

Related questions

0 votes
0 votes
0 answers
4
vg653 asked Dec 18, 2018
458 views
The Minimum number of possible edges in an undirected graph with n vertices and k components is ______