The two-phase locking protocol consists of two phases:
-
Phase 1: The Lock Acquisition Phase:
If a transaction T wants to read an object, it needs to obtain the S(shared) lock. If T wants to modify an object, it needs to obtain X(exclusive) lock. No conflicting locks are granted to a transaction.
New locks on items can be acquired but no lock can be released till all the locks required by the transaction are obtained.
-
Phase 2: Lock Release Phase:
The existing locks can be released in any order but no new lock can be acquired after a lock has been released. The locks are held only till they are required.