Professional Documents
Culture Documents
Consider the three schedules below. For each one, answer the following questions and provide detailed
explanation or proof for your answer:
Note: “is this possible under a strict 2PL protocol” means does there exist a way to lock the items as
needed, so that each transaction goes through a growing and a shrinking phase.
Schedule 1
T1 T2 T3
R(A)
R(B)
W(C)
R(C)
W(B)
W(A)
R(B)
R(B)
commit W(C)
commit
abort
Schedule 2
T1 T2
R(A)
R(B)
R(A)
W(A)
R(C)
W(B)
commit W(C)
commit
Schedule 3
T1 T2 T3
R(A)
R(B)
R(C)
R(C)
R(B)
W(A)
R(C)
W(C)
W(B)
commit W(C)
commit
R(A)
commit
Problem 2
T3 T4
R(A)
A := A+1
W(A)
R(A)
R(B)
B := B-1
A := A + 1
W(A)
W(B)
R(B)
R(B)
B := B-1
W(B)
a) Draw a precedence graph (aka conflict graph). This is the graph where nodes represent transactions and
there's a directed edge from T_i to T_j if there is a pair of conflicting instructions and the one in T_i is
earlier in the schedule than the one from T_j.
c) Can the schedule arise if the transactions follow two-phase locking (without lock upgrades)?
If so, show the points in the schedule at which lock-X requests are granted and at which unlock
instructions are executed. (Insert the locking instructions without changing the relative order of any of the
instructions that are shown. For lock acquisitions, put the instruction at the latest point when the can be
granted, while following all rules of 2PL and holding necessary locks to read/write data.)
Consider the following schedule on five transactions, where lock-X() and lock-S() denote requests for
exclusive and shared locks, respectively, Is the schedule deadlocked? Prove your answer. If it is
deadlocked, discuss one method to recover. If it is not deadlocked, how would you avoid a deadlock?
T1 T2 T3 T4 T5
lock-S(A)
lock-S(C)
lock-X(B)
lock-X(D)
lock-S(E)
lock-S(E)
lock-S(G)
lock-S(A)
lock-X(C)
lock-S(C)
lock-X(G)
lock-S(D)
lock-S(B)
lock-X(B)
lock-S(A)