2,274 views
2 votes
2 votes
According to 2-phase locking protocol, if a transaction acquires an exclusive lock on any object, another transaction cannot obtain any kind of lock on it till the first transaction unlocks it.

Is the reverse also true, i.,e., if a transaction acquires a shared lock on any item, then any other interleaving transaction cannot acquire any kind of lock on it..? or it cannot acquire exclusive lock, but can acquire shared lock. ?

2 Answers

Best answer
3 votes
3 votes

If a transaction is holding a shared lock on a data item then only shared lock is possible by any other transaction on the same item.

or 

If a transaction is holding a xclusive lock on a data item then neither shared nor xclusive is possible by any other transaction on the same item

selected by
3 votes
3 votes

  let there be two transaction T1 and T2

T1                               T2

s(A)r1(A)

                           x(B) w2(B)

                           x(A) w2(A)            here it is denied T2 waits for T1 

s(B)r1(B)  here it is denied T1 waits for T2 

so its a deadlock situation.

Related questions

1 votes
1 votes
1 answer
1
Shivam Gupta 3 asked Aug 3, 2017
617 views
T1: r1(x)w1(x)r1(y)w1(y)T2: r2(y)w2(y)L is xclusive lock and U is unlock L1(y)L1(X)R1(Y)W1(Y)R1(X)W1(X)U1(X)U1(Y)L2(Y)R2(Y)W2(Y)U2(Y)?IS THIS SCHEDULE VALID UNDER A 2 PH...
1 votes
1 votes
1 answer
3
palashbehra5 asked Jan 17, 2022
964 views
Given Problem : S1 can be shown allowed under 2PL.However, the solution that they have provided for S2 : Seems wrong, as So, is S2 allowed under 2PL, or the answer give...
1 votes
1 votes
0 answers
4