Skip to content

Commit 9cb7487

Browse files
authoredJun 19, 2024
Enforce consistent naming scheme (#13)
In Chapter 1 Background, renamed variable in threadB() function for clarity and consistency: - Renamed `my_v` to `b_v` in threadB(). In Chapter 2 Enforcing law and order, renamed variable in threadB() function to improve consistency: - Renamed `bv` to `b_v` in threadB().
1 parent 8a2fb8d commit 9cb7487

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎concurrency-primer.tex

+5-5
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ \section{Background}
204204
{
205205
// Await a value change and read it.
206206
while (!v_ready) { /* wait */ }
207-
const int my_v = v;
208-
// Do something with my_v...
207+
const int b_v = v;
208+
// Do something with b_v...
209209
}
210210
\end{ccode}
211211
We must ensure that other threads only observe \textit{A}'s write to \cc|v_ready| \emph{after A's} write to \cc|v|.
@@ -296,12 +296,12 @@ \section{Enforcing law and order}
296296
}
297297
\end{ccode}
298298
\begin{ccode}
299-
int bv;
299+
int b_v;
300300

301301
void *threadB()
302302
{
303303
while(!v_ready) { /* wait */ }
304-
bv = v;
304+
b_v = v;
305305
/* Do something */
306306
}
307307
\end{ccode}
@@ -314,7 +314,7 @@ \section{Enforcing law and order}
314314
Informally, we can think of atomic variables as rendezvous points for threads.
315315
By making \monobox{v\_ready} atomic,
316316
\monobox{v = 42}\, is now guaranteed to happen before \monobox{v\_ready = true}\, in thread~\textit{A},
317-
just as \monobox{my\_v = v}\, must happen after reading \monobox{v\_ready}\,
317+
just as \monobox{b\_v = v}\, must happen after reading \monobox{v\_ready}\,
318318
in thread~\textit{B}.
319319
Formally, atomic types establish a \textit{single total modification order} where,
320320
``[\ldots] the result of any execution is the same as if the reads and writes occurred in some order, and the operations of each individual processor appear in this sequence in the order specified by its program.''

0 commit comments

Comments
 (0)
Please sign in to comment.