Skip to content

Commit a48f633

Browse files
committed
Replace the execution results of code with LaTeX table syntax
1 parent 6c1b062 commit a48f633

File tree

1 file changed

+44
-13
lines changed

1 file changed

+44
-13
lines changed

concurrency-primer.tex

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,19 +1137,50 @@ \subsubsection{Sequential consistency (SC)}
11371137
\end{ccode}
11381138

11391139
If this program satisfies sequential consistency, then for Thread 1, \monobox{x = 1} must occur before \monobox{y = 1}, and for Thread 2, \monobox{r1 = y} must occur before \monobox{r2 = x}.
1140-
For the entire program, the following six execution orders are possible:
1141-
1142-
\begin{verbatim}
1143-
| x = 1 | x = 1 | x = 1 |
1144-
| y = 1 | r1 = y(0) | r1 = y(0) |
1145-
| r1 = y(1) | y = 1 | r2 = x(1) |
1146-
| r2 = x(1) | r2 = y(1) | y = 1 |
1147-
+-------------------+-------------------+-------------------+
1148-
| r1 = y(0) | r1 = y(0) | r1 = y(0) |
1149-
| x = 1 | x = 1 | r2 = x(0) |
1150-
| y = 1 | r2 = x(1) | x = 1 |
1151-
| r2 = x(1) | y = 1 | y = 1 |
1152-
\end{verbatim}
1140+
For the entire program, the following six execution orders are possible:
1141+
1142+
\begin{center}
1143+
\noindent
1144+
\begin{tabular}{|c|c|c|} \hline
1145+
\begin{lstlisting}
1146+
x = 1
1147+
y = 1
1148+
r1 = y(1)
1149+
r2 = x(1)
1150+
\end{lstlisting}&
1151+
\begin{lstlisting}
1152+
x = 1
1153+
r1 = y(0)
1154+
y = 1
1155+
r2 = y(1)
1156+
\end{lstlisting}&
1157+
\begin{lstlisting}
1158+
x = 1
1159+
r1 = y(0)
1160+
r2 = x(1)
1161+
y = 1
1162+
\end{lstlisting}\\ \hline
1163+
\begin{lstlisting}
1164+
r1 = y(0)
1165+
x = 1
1166+
y = 1
1167+
r2 = x(1)
1168+
\end{lstlisting}&
1169+
\begin{lstlisting}
1170+
r1 = y(0)
1171+
x = 1
1172+
r2 = x(1)
1173+
y = 1
1174+
\end{lstlisting}&
1175+
\begin{lstlisting}
1176+
r1 = y(0)
1177+
r2 = x(0)
1178+
x = 1
1179+
y = 1
1180+
\end{lstlisting}\\ \hline
1181+
\end{tabular}
1182+
\captionof{table}{6 possible execution orders of the message passing litmus test.}
1183+
\end{center}
11531184

11541185
Observing these orders, we see that none result in \monobox{r1 = 1} and \monobox{r2 = 0}.
11551186
Thus, sequential consistency only allows the outcomes \monobox{(r1, r2)} to be \monobox{(1, 1)}, \monobox{(0, 1)}, and \monobox{(0, 0)}.

0 commit comments

Comments
 (0)