Skip to content

Commit e8b81b4

Browse files
committed
Fix typo
1 parent 11c2494 commit e8b81b4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

concurrency-primer.tex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ \subsection{ABA problem}
905905

906906
In the example provided, the presence of ABA problem results in thread A being unaware that variable \monobox{v} has been altered.
907907
Since the comparison result indicates \monobox{v} unchanged, \monobox{v + 10} is swapped in.
908-
Here sleeping is only used to ensure the occurance of ABA problem.
908+
Here sleeping is only used to ensure the occurrence of ABA problem.
909909
In real world scenario, instead of sleeping, thread A could paused by being context switched for other tasks, including being preempted by higher priority tasks.
910910
This example seems harmless, but things can get nasty when atomic \textsc{RMW} operations are used in more complex data structures.
911911

@@ -928,9 +928,9 @@ \subsection{ABA problem}
928928
\item Thread A is preempted.
929929
\item Thread B claims the job and successfully updates \monobox{thrd\_pool->head->prev}.
930930
\item Thread B sets thread pool state to idle.
931-
\item Main thread fininshes waiting and adds more jobs.
931+
\item Main thread finishes waiting and adds more jobs.
932932
\item Memory allocator reuses the recently freed memory as new jobs addresses.
933-
\item Fortunately, the first added job has the same address as the one thread A holded.
933+
\item Fortunately, the first added job has the same address as the one thread A held.
934934
\item Thread A is back in running state. The comparison result is equal so it updates \monobox{thrd\_pool->head->prev} with the old \monobox{job->prev}, which is already a dangling pointer.
935935
\item Another thread loads the dangling pointer from \monobox{thrd\_pool->head->prev}.
936936
\end{enumerate}
@@ -963,7 +963,7 @@ \subsection{ABA problem}
963963
\inputminted{c}{./examples/rmw_example_aba.c}
964964

965965
Notice that, in the \monobox{struct idle\_job}, a union is used for type punning, which bundles the pointer and version number for compare-and-swap.
966-
Directly casting a job pointer to a pointer that points to a 16-byte object is undefined behavior (due to having different alignment), thus type punnined is used instead.
966+
Directly casting a job pointer to a pointer that points to a 16-byte object is undefined behavior (due to having different alignment), thus type punning is used instead.
967967
By using this techniques, \monobox{struct idle\_job} still can be accessed normally in other places, minimizing code modification.
968968
Compiler optimizations are conservative on type punning, but it is acceptable for atomic operations.
969969
See \secref{fusing}.

0 commit comments

Comments
 (0)