Skip to content

Commit 1548925

Browse files
committed
Tweak annotations
1 parent cc5382b commit 1548925

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

Diff for: concurrency-primer.tex

+10-12
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ \subsection{Test and set}
405405
\clang{} and \cplusplus{} offer a type dedicated to this purpose, called \monobox{atomic\_flag}.
406406
We could use it to build a simple spinlock:
407407
\label{spinlock}
408-
\begin{cppcode}
408+
\begin{ccode}
409409
atomic_flag af = ATOMIC_FLAG_INIT;
410410

411411
void lock()
@@ -414,7 +414,7 @@ \subsection{Test and set}
414414
}
415415

416416
void unlock() { atomic_flag_clear(&af); }
417-
\end{cppcode}
417+
\end{ccode}
418418
If we call \cc|lock()| and the previous value is \cc|false|,
419419
we are the first to acquire the lock,
420420
and can proceed with exclusive access to whatever the lock protects.
@@ -555,7 +555,7 @@ \section{Sequential consistency on weakly-ordered hardware}
555555
Other systems programming languages like D and Rust have converged on similar models.}
556556
Let's examine \textsc{Arm}, since it is both popular and straightforward.
557557
Consider the simplest atomic operations: loads and stores.
558-
Given some \cpp|atomic_int foo|,
558+
Given some \cc|atomic_int foo|,
559559
\newline
560560
% Shield your eyes.
561561
% Essentially,
@@ -564,12 +564,12 @@ \section{Sequential consistency on weakly-ordered hardware}
564564
% 3. In the middle, place an arrow for each (futzing with height a bit)
565565
% with the text "becomes" over it.
566566
\begin{minipage}{0.35\linewidth}
567-
\begin{cppcode}
567+
\begin{ccode}
568568
int getFoo()
569569
{
570570
return foo;
571571
}
572-
\end{cppcode}
572+
\end{ccode}
573573
\end{minipage}
574574
\raisebox{-1ex}{
575575
\begin{tikzpicture}
@@ -588,12 +588,12 @@ \section{Sequential consistency on weakly-ordered hardware}
588588
\end{minipage}
589589
%Similarly,
590590
\begin{minipage}{0.35\linewidth}
591-
\begin{cppcode}
591+
\begin{ccode}
592592
void setFoo(int i)
593593
{
594594
foo = i;
595595
}
596-
\end{cppcode}
596+
\end{ccode}
597597
\end{minipage}
598598
\raisebox{-1ex}{
599599
\begin{tikzpicture}
@@ -631,9 +631,9 @@ \section{Implementing atomic read-modify-write operations with LL/SC instruction
631631
This mechanism is illustrated through an atomic fetch and add example.
632632

633633
On \textsc{Arm},
634-
\begin{cppcode}
634+
\begin{ccode}
635635
void incFoo() { ++foo; }
636-
\end{cppcode}
636+
\end{ccode}
637637
compiles to:
638638
\begin{lstlisting}[language={[ARM]Assembler}]
639639
incFoo:
@@ -759,9 +759,7 @@ \section{Memory orderings}
759759
\begin{cppcode}
760760
void lock()
761761
{
762-
while (af.test_and_set(memory_order_acquire)) {
763-
/* wait */
764-
}
762+
while (af.test_and_set(memory_order_acquire)) { /* wait */ }
765763
}
766764

767765
void unlock()

0 commit comments

Comments
 (0)