110/212
\begin{frame}
  \frametitle{Deadlocks}

  \begin{alertblock}{}
    Like many lock-based protocols, 2PL has the risk of \emph{deadlocks}.
  \end{alertblock}  
  \pause
  
  \begin{exampleblock}{A Deadlock Situation}
    \begin{tcenter}
    \begin{tabular}{|l|l|}
    \hline
    \emph{Transaction 1} & \emph{Transaction 2}  \\
    \hline
    & \\
    \mpause[1]{ \textcolor{dgreen}{$\fun{xlock}(\var{A})$} } & \\
    \mpause[1]{ \vdots} &  \mpause[2]{ \textcolor{dgreen}{$\fun{xlock}(\var{B})$} }\\
    \mpause[1]{ do something } & \mpause[2]{ \vdots } \\
    \mpause[1]{ \vdots } &  \mpause[2]{  do something } \\
    \mpause[3]{ \textcolor{gray}{$\fun{lock}(\var{B})$} } & \mpause[2]{ \vdots } \\
    \mpause[4]{ \alert{(waiting for $T_2$ to unlock B)} } & \mpause[5]{ \textcolor{gray}{$\fun{lock}(\var{A})$} } \\
    & \mpause[6]{ \alert{(waiting for $T_1$ to unlock A)} } \\
    \hline
    \end{tabular}
    \end{tcenter}
  \end{exampleblock}
  \pause\pause\pause\pause\pause\pause\pause
  
  \begin{alertblock}{}
    Both transactions would wait for each other \emph{indefinitely}.\\
    \emph{We need to detect deadlocks!}
  \end{alertblock}
\end{frame}