DBMS- Two Phase Locking(2PL)
Q) What is two phase locking ?
Ans :- 1) Two phase locking is also called as 2PL.
2) Two phase locking is a method or protocol of controlling concurrent processing .
3)In this all locking operations precede the first unlocking operation and guarantees Serializability.
4)Transaction only in 2PL if all locking operations (READ_LOCK,WRITE_LOCK) precede the first unlock operation in the transaction.
5) Two phase locking defines how transactions acquire and relinquish locks.
6) In this transaction must follow two locking phase for locking or unlocking
a)Growing Phase b)Shrinking Phase
7) Growing Phase:- In growing phase transaction acquires all the required locks without unlocking any data.
8) Shrinking phase :- In shrinking phase transaction releases all locks and cannot obtain any new lock.
The above two phase governed by the following rules :
i) Two transactions cannot have conflicting locks.
ii) No unlock operation can precede a lock operation in the same transaction .
iii) No data are affected by other transaction until all locks are obtained, that is, until the transaction is in its locked point.
9)Consider the two transaction T1 and T2 ,suppose transaction T2 would request an exclusive lock on 'X'. However, this request can not be granted until transaction T1 releases its exclusive lock on 'X'. and transaction T2 will be suspended.
10) Transaction T1 commit after read and write operation on 'X' and at that time locks are released. Now the lock request of transaction T2 is granted, end it proceed
11) The graph of two phase locking (2PL).
Fig: Two phase locking (2PL) |
0 comments:
Post a Comment