You are on page 1of 4

NYU Tandon School of Engineering

Computer Science and Engineering


CS6083, Fall 2023

Problem Set #5 – Not Graded, For Practice Only


Problem 1

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.

a) Is this schedule conflict-serializable?


b) Is this schedule recoverable if the transactions complete in the order specified?
c) Is this schedule cascadeless?
d) Is this schedule possible under a (non-strict) 2PL protocol?
e) Is this schedule possible under a strict 2PL protocol?
f) Is this schedule possible under a rigorous 2PL protocol

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

Consider two transactions, executing the following schedule:

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.

b) State whether the schedule is conflict serializable.

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.)

If the schedule cannot arise using 2PL, explain why not.


Problem 3

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)

You might also like