-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "Memory consistency models" subsection to "Memory orderings" section #16
base: main
Are you sure you want to change the base?
Conversation
concurrency-primer.tex
Outdated
y = 1; r2 = x; | ||
\end{ccode} | ||
|
||
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}. For the entire program, the following six execution orders are possible: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use rich LaTeX annotations to represent the following.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean I should use \cc{...}
or \cpp{...}
instead of \monobox{...}
?
concurrency-primer.tex
Outdated
|
||
\subsubsection{Total store order (TSO)} | ||
|
||
Although sequential consistency is considered the "golden standard" for multi-threaded programs, its many constraints limit performance optimization. As a result, it is rarely implemented in modern processors. Instead, more relaxed memory models are used, such as the total store order (TSO) memory model adopted by the x86 architecture. One can envision the hardware roughly as follows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the quotation mark. See https://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/QuotDash.html
\subsection{Memory consistency models} | ||
|
||
When a program is compiled and executed, it doesn't always follow the written order. | ||
The system may change the sequence and optimize it to simulate line-by-line execution, as long as the final result matches the expected outcome. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should address the impact from modern microprocessors and optimizing compilers.
When a program is compiled and executed, it doesn't always follow the written order. | ||
The system may change the sequence and optimize it to simulate line-by-line execution, as long as the final result matches the expected outcome. | ||
|
||
This requires an agreement between the programmer and the system (hardware, compiler, etc.), ensuring that if the rules are followed, the execution will be correct. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge the statement into the previous paragraph.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase the latest main
branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of git merge
, do git rebase
.
1. split setences into separate lines 2. change the quotation marks "..." as ``...''
- Changed "doesn't" to "does not" for formal English writing - Fixed the inconsistency of quotation marks - Merged related statements into one paragraph
|
||
The write order seen by one thread can differ from the order seen by other threads because write operations can be reordered during propagation. | ||
However, reads and writes to the same memory address must still follow a total order. | ||
Therefore, the following litmus test cannot result in \monobox{r1 = 1}, \monobox{r2 = 2}, but \monobox{r3 = 2}, \monobox{r4 = 1}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide some information about running Litmus tests.
|
||
\subsubsection{Sequential consistency (SC)} | ||
|
||
In the 1970s, Leslie Lamport proposed the most common memory consistency model, sequential consistency (SC), defined as follows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some references at the end of this document.
Any progress? |
This pull request aims to enhance the comprehensiveness of the “Memory orderings” section of this book. Currently, the section primarily covers memory orders defined in C11/C++11 but lacks discussion on hardware assumptions regarding memory consistency. Thus I made the following changes: