10/212
\begin{frame}
  \frametitle{Concurrent Access: Lost Update}
  
  My wife and I have \emph{credit cards for the same account}.
  \smallskip
    
  What if we use the cards at the same time (\emph{concurrently})?
  \pause
  
  \begin{exampleblock}{Concurrent ATM Transaction}
%     I withdraw 100 Euro, my wife 200 Euros.\\[.5ex]
    \begin{tcenter}\small
    \begin{tabular}{|l|l|c|}
    \hline
    \emph{me (withdraws 100)} 
      & \emph{my wife (withdraws 200)}
      & \emph{state} \\
    \hline
    $\balance{1200} \set \fun{read}(\var{account})$
     & 
     & 1200 \\[-1.5ex]
     & $\balance{1200} \set \fun{read}(\var{account})$
     & 1200 \\[-1.5ex]
    $\balance{1100} \set \balance{1200}-100$
     & 
     & 1200 \\[-1.5ex]
     & $\balance{1000} \set \balance{1200}-200$
     & 1200 \\[0ex]
     & $\fun{write}(\var{account}, \balance{1000})$
     & 1000 \\[-1.5ex]
    $\fun{write}(\var{account}, \balance{1100})$
     & 
     & 1100 \\
    \hline
    \end{tabular}
    \end{tcenter}
  \end{exampleblock}
  \pause
  
  \begin{alertblock}{}
    The update of my wife was lost during this execution. Lucky me!
  \end{alertblock}
  \pause

  \begin{goal}{}
    This is known as \emph{lost update anomaly}.
  \end{goal}
\end{frame}