304 views
0 votes
0 votes

With reference to the GATE IT 2007 | Question : 66

In the following article from GeeksForGeeks : Lock Compatibility Diagram

It can be clearly seen that if a transaction Ti owns a Shared lock on A, then a transaction Tj cannot take an Exclusive lock on A.

But in the question from 2007, we can see in the correct marked option (c), that transaction T1 takes a Lock_S(A) and then without waiting for it to be unlocked, Lock_X(A) is taken by T2, and so is the case for B, but here T2 first takes Shared lock on B and then T1 takes exclusive lock on B.

I’m confused as to what is being implied here ? Does it mean that Lock_X(A) call in T2 will wait for T1, and T1 will wait for Lock_X(B) from T2, so hence a deadlock ?

1 Answer

Best answer
1 votes
1 votes
If you read question care fully then the operations given are for transaction and no mention of order is given. That is maybe the operations may interleave or maybe the could execute in serial order. T1 takes shared lock and T2 takes exclusive lock, but when? In what order? Who takes lock first? Or maybe t2 executes after t1 finishes i.e. these are occuring serially.

To clear the confusion you must understand that individual actions of transactions are given and not the schedule meaning we can't pinpoint if some operation of T1 occurs before that of t2, we can pinpoint only the order in the same transaction i.e. inside t2 lock is acquired first before writing. And released after commit. Also all options except c violate some rule of strict 2pl.

In a tranction writes without taking exclusive lock. In option d exclusive lock is released before commit which is not allowed, in option b exclusive lock is taken for read operation which isn't invalid in itself but it must be released after commit. Only c follows all rules of strict 2pl.

Also strict 2pl doesn't care about deadlock. Let it happen if it happens.
selected by

Related questions

53 votes
53 votes
5 answers
1
Ishrat Jahan asked Oct 30, 2014
18,164 views
Consider the following two transactions$: T1$ and $T2.$$\begin{array}{clcl} T1: & \text{read (A);} & T2: & \text{read (B);} \\ & \text{read (B);} & & \text{read (A);} \\ ...
5 votes
5 votes
2 answers
2
Ishrat Jahan asked Oct 29, 2014
6,276 views
In the Spiral model of software development, the primary determinant in selecting activities in each iteration isIteration sizeCostAdopted process such as Rational Unifie...
46 votes
46 votes
5 answers
4