Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/lsp4you/public_html/connect.php on line 2 LSP4YOU - Learner's Support Publications

Two Phase Locking (2PL)

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.