Two-Phase Locking (2PL) Protocol
A transaction is two-phase locked if:
- before reading x, it sets a read lock on x
- before writing x, it sets a write lock on x
- it holds each lock until after it executes the corresponding operation
- after its first unlock operation, it requests no new locks
Each transaction sets locks during a growing phase and releases them during a shrinking phase.
Example - on the previous page T2 is two-phase locked, but not T1 since ru1[x] < wl1[y]