GATE | Gate IT 2007 | Question 64
Shared locks are used for Read,exclusive locks are used for Write data. one exclusive lock can not take other exclusive lock which is already taken by other schedule as it will lead to deadlock. Requirements to follow Strict 2PL:
1. Exclusive locks should be released after the commit (Releasing exclusive lock after commit restrict the deadlock condition. i.e. we cannot get lock on item were exclusive lock already taken.
2. No Locking can be done after the first Unlock and vice versa.
option (A): Incorrect because to write B,S1 needs exclusive lock on B and to write A,S2 needs exclusive Lock on A. that’s why it is incorrect.
option (B): Incorrect because one exclusive lock cannot take other’s Exclusive Lock. here, S1 has taken exclusive lock on item A, S2 has taken exclusive lock on item B so now S1 can’t take exclusive lock on item B and S2 can’t take exclusive lock on item A. that’s why it is incorrect.
option (C): Correct as it is following all the three requirement for strict 2PL. Here,schedule S1 releases exclusive lock on B after commit and schedule S2 releases exclusive lock on A after commit.(condition 1 satisfied)
option(D): incorrect as according to condition 1,Exclusive locks should be released after the commit. here,schedule S1 releases exclusive lock on B before commit and schedule S2 releases exclusive lock on A before commit. Hence it is incorrect.
This solution is contributed by Nitika Bansal .
Quiz of this Question