From 9cb7487883c0992e75dcb35ee34de0ca8d908e17 Mon Sep 17 00:00:00 2001 From: Wei-Hsin Yeh Date: Thu, 20 Jun 2024 01:07:09 +0800 Subject: [PATCH] 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(). --- concurrency-primer.tex | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/concurrency-primer.tex b/concurrency-primer.tex index 631dd2d..12fed1d 100644 --- a/concurrency-primer.tex +++ b/concurrency-primer.tex @@ -204,8 +204,8 @@ \section{Background} { // Await a value change and read it. while (!v_ready) { /* wait */ } - const int my_v = v; - // Do something with my_v... + const int b_v = v; + // Do something with b_v... } \end{ccode} 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} } \end{ccode} \begin{ccode} -int bv; +int b_v; void *threadB() { while(!v_ready) { /* wait */ } - bv = v; + b_v = v; /* Do something */ } \end{ccode} @@ -314,7 +314,7 @@ \section{Enforcing law and order} Informally, we can think of atomic variables as rendezvous points for threads. By making \monobox{v\_ready} atomic, \monobox{v = 42}\, is now guaranteed to happen before \monobox{v\_ready = true}\, in thread~\textit{A}, -just as \monobox{my\_v = v}\, must happen after reading \monobox{v\_ready}\, +just as \monobox{b\_v = v}\, must happen after reading \monobox{v\_ready}\, in thread~\textit{B}. Formally, atomic types establish a \textit{single total modification order} where, ``[\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.''