598 views

Consider the following interleaved schedule with two transactions T1 and T2. The Two-Phase Locking Protocol is followed for achieving concurrency control. Which of the following statements is true with respect to the given schedule?

1. The schedule is equivalent to the serial schedule T2 ; T1
2. The schedule is equivalent to the serial schedule T1 ; T2
3. The schedule results in a deadlock
4. The schedule is not permitted as per Two Phase Locking Protocol

1 comment

@Applied Course schedule was not given in the exam. Please edit the question.

$\begin{array}{|c|c|c|} \hline \text{Line Number} & T1 & T2 \\ \hline 1 & S(A) & \\ \hline 2 & R(A) & \\ \hline 3 & & S(A) \\ \hline 4 & & R(A) \\ \hline 5 & & X(B) \\ \hline 6 & & R(B) \\ \hline 7 & & W(B) \\ \hline 8 & & \text{Commit} \\ \hline 9 & X(C) & \\ \hline 10 & R(C) & \\ \hline 11 & W(C) & \\ \hline 12 & \text{Commit} & \\ \hline \end{array}$
Explanation: The schedule starts off by executing two statements of transaction T1, in line numbers $1$ and $2$. T1 obtains a shared lock on object A and reads object. At this point T1 is suspended and control is transferred to T2. Then, in lines $3$ to $8$, transaction T2 obtains a shared lock on object A, reads object A, obtains an exclusive lock on object B, reads and writes object B, and finally commits. At this point T2 has completed execution before T1, and all the locks held by it are released. T1 resumes its execution in line number $9$, it obtains an exclusive lock on object C, reads and writes C, and then commits. T1 has also completed its execution. This schedule has reduced to the serial schedule T2 followed by T1.

1 comment

why not T1 followed by T2

if we draw precedence graph it will be T1 T2 not edges..so why can't we start with T