Two Phase Locking Protocol (2PL):
The Two Phase Locking Protocol ensures Serializability. This protocol requires thateach transaction issue lock and unlock requests in two phases:
1. Growing Phase:
A transaction may obtain locks but may not release any lock.
2. Shrinking Phase:
A transaction may release locks but may not obtain any new locks.A transaction is said to follow Two Phase Locking Protocol if all locking operations precede the first unlock operation in a transaction. In other words release of locks on all dataitems required by the transaction have been acquired both the phases discussed earlier aremonotonic. The number of locks are decreasing in the 2
phase. Once a transaction starts torequest any further locks.Transaction T1 shown in Figure 1 below transfers $50 from account B to account Aand transaction T2 in next Figure 2 displays the total amount of money in account A and B.Figure 1:T1 :Lock_X (B);Read (B);B := B – 50;Write (B);Unlock (B);Lock_X (A);Read (A);A := A + 50;Write (A);Unlock (A);