Lock-Based Protocols and Basic 2PL Explained: Lock Compatibility, Phases and a Worked Schedule
Learn to test a concrete schedule for Basic 2PL by tracing S and X locks, lock points, waits, unlocks, values, and the resulting precedence graph.
KnowledgeGate Team
Exam prep & CS education

Memorising that two-phase locking has two phases is easy. The harder task is deciding whether a concrete interleaved schedule actually obeys Basic 2PL. Use a fixed method: check lock compatibility, mark each transaction's lock point, inspect every unlock, and then derive the serial order. Basic 2PL guarantees conflict serializability, but it does not by itself guarantee deadlock freedom or strict execution.
Lock-based protocols in DBMS: what S and X locks permit
A shared lock S(A) gives permission to read item A. An exclusive lock X(A) gives permission to read and write A. Operationally, a read needs either S or X, while a write needs X.
Requested lock | Existing | Existing |
|---|---|---|
| Grant | Wait |
| Wait | Wait |
Compatibility is checked per data item. A transaction holding X(A) does not block an unrelated lock request on B. Also distinguish a request from a grant: a waiting request is not yet a held lock, and an unlock releases a granted lock.
The wider Transactions and Concurrency Control in DBMS guide places these locks inside transaction schedules. The CS Fundamentals category provides the broader DBMS learning route.
Basic 2PL: growing phase, lock point and shrinking phase
During the growing phase, a transaction may acquire new locks or upgrade S to X. It may not release or downgrade any lock. Its lock point is the instant it obtains its final lock, not its first lock and not necessarily its commit.
The first unlock or downgrade starts the shrinking phase. From that instant, the transaction may release locks but may acquire no new one. This is legal:
X1(A), R1(A), W1(A), X1(B), R1(B), W1(B), U1(A), U1(B), C1
Here, X1(B) is T1's lock point and U1(A) begins shrinking. By contrast, S3(A), R3(A), U3(A), X3(B), W3(B) is illegal because T3 requests a new lock after its first unlock.
Basic 2PL worked example: follow every value and lock state
Let A = 100 and B = 50. T1 transfers 20 from A to B, and T2 reads B after T1.
Step | Operation | Lock state on A | Lock state on B | Result or wait |
|---|---|---|---|---|
1 | Grant |
| None | Granted |
2 |
|
| None | Read 100; write |
3 | Grant |
|
| Granted; T1 lock point |
4 |
|
|
| Read 50; write |
5 | Request |
|
| Wait, |
6 |
| None |
| T1 enters shrinking phase |
7 |
| None | None; | T1 releases B |
8 |
| None | None; | T1 commits |
9 | Grant | None |
| T2 reads 70; T2 lock point |
10 |
| None | None | T2 enters shrinking phase |
11 |
| None | None | T2 commits |
T1 leaves A = 100 - 20 = 80 and B = 50 + 20 = 70. T2 observes 70, so the final values are A = 80 and B = 70. T1 obtains no lock after U1(A), and T2 obtains no lock after U2(B). Both therefore obey Basic 2PL.

Why Basic 2PL produces a conflict-serializable schedule
The only cross-transaction conflict in this schedule is W1(B = 70) before R2(B = 70). The precedence graph therefore has one edge, T1 -> T2. There is no edge back to T1, so the graph is acyclic and the conflict-equivalent serial order is T1 followed by T2.
The general reason comes from lock points. For a conflict edge Ti -> Tj, Ti must release its incompatible lock before Tj can obtain its lock. Under 2PL, Ti's lock point occurs before that release, while Tj's lock point occurs at or after its later acquisition. The lock points must therefore order Ti before Tj, so they cannot form a cycle.
This proves that schedules generated by 2PL are conflict serializable. It does not prove the converse: a conflict-serializable schedule need not have been generated by 2PL.

Basic 2PL limitations and the stricter variants
Basic 2PL can deadlock even while both transactions are growing. Suppose T4 gets X4(A) and T5 gets X5(B). T4 then requests X4(B) and waits, while T5 requests X5(A) and waits. Neither can proceed.
It can also permit cascading rollback. Start with X = 40. T6 gets X6(X), writes X = 55, and unlocks X before committing. T7 then gets S7(X) and reads 55. This obeys Basic 2PL, but if T6 aborts, T7 has consumed an uncommitted value and must also roll back.
Protocol | Lock rule | Main consequence |
|---|---|---|
Basic 2PL | Grow, then shrink | Conflict serializability |
Conservative 2PL | Obtain every required lock before execution | Avoids deadlock, with lower concurrency |
Strict 2PL | Hold exclusive locks until commit or abort | Prevents reads or overwrites of uncommitted writes |
Rigorous 2PL | Hold shared and exclusive locks until commit or abort | Stronger release discipline |
Basic 2PL traps that turn correct-looking schedules into wrong answers
Two phase does not mean two lock operations. It means every acquisition precedes that transaction's first release.
Phases are per transaction. Different transactions can be growing or shrinking at the same point in the global schedule.
Upgrades and downgrades count. An
StoXupgrade is an acquisition and belongs in growing. It must wait if another transaction holdsSon the item. AnXtoSdowngrade is a release and begins shrinking.Do not confuse guarantees. Basic 2PL gives conflict serializability, not deadlock freedom, cascadelessness, or strictness.
Test S8(A), R8(A = 80), X8(B), W8(B = 75), U8(A), X8(C). It violates Basic 2PL because X8(C) follows the first unlock. Moving X8(C) before U8(A) is the minimum repair.
How GATE tests lock-based protocols and Basic 2PL
The GATE 2026 Computer Science syllabus published by IIT Guwahati includes transactions and concurrency control under DBMS.
Common reasoning formats are completing an S/X compatibility table, testing a lock sequence for 2PL, drawing a wait-for or precedence graph, and distinguishing Basic, conservative, strict, and rigorous 2PL. For immediate practice, use DBMS Transaction MCQs: 12 Solved (ACID, Locking).
Your 30-second checklist is: mark every grant and unlock per transaction, circle its first unlock, reject any later acquisition, resolve incompatible requests as waits, draw the conflict edges, and read the serial order.
Lock-based protocols and Basic 2PL: the short version and next step
Keep four lines in memory:
S + Sis allowed.Any pair involving
Xconflicts.Growing means acquire but do not release.
Shrinking means release but do not acquire.
Lock-point order gives the conflict-equivalent serial order. If you need the wider subject sequence, CS Fundamentals for Placements by Sanchit Sir provides that route. If you already know the theory and need timed GATE application, use the GATE Test Series.
Now redraw the worked schedule from memory. Your version should end with A = 80, B = 70, show the waiting S2(B) request, and produce the edge T1 -> T2.
Keep learning
Lock-Based Protocols & Basic 2PL MCQs: 12 Solved Questions with Explanations
Solve 12 published Basic 2PL MCQs, from growing and shrinking phases to lock compatibility, precedence graphs, deadlock, strictness and SQL update order.
TypeScript vs C# Typing: Structural Compatibility, Nominal Identity, Generics and Runtime Checks
Follow one User/Admin example through TypeScript and C# to predict assignments, generic conversions, branded IDs, and JSON behaviour at runtime.
Strict, Rigorous and Conservative 2PL in DBMS: Differences, Schedules and Traps
Learn the exact lock-acquisition and release rules that separate basic, strict, rigorous and conservative 2PL. Trace an abort, a commit-order reversal and a deadlock-free transfer.
Concurrency Control in DBMS: Anomalies, Serializability, Locking and 2PL with Worked Examples
Connect the full DBMS concurrency-control chain through one precedence-graph schedule, strict 2PL examples, timestamp rules and recovery checks.





