Mismatch between code:
X.fetch_add(5, Relaxed); X.fetch_add(10, Relaxed);
And text:
... only one possible order of modification of X: 0→5→15. It starts at zero, then becomes five, and is finally changed to fifteen. Threads cannot observe any values from X that are inconsistent with this total modification order. This means that "0 0 0 0", "0 0 5 15", and "0 15 15 15" are some of the possible results from the print statement in the other thread, while an output of "0 5 0 15" or "0 0 10 15" is impossible.
Possible fix: Either change 10 to 15 in the code, or change the text:
... only one possible order of modification of X: 0→5→10. It starts at zero, then becomes five, and is finally changed to ten. Threads cannot observe any values from X that are inconsistent with this total modification order. This means that "0 0 0 0", "0 0 5 10", and "0 10 10 10" are some of the possible results from the print statement in the other thread, while an output of "0 5 0 10" or "0 0 10 15" is impossible.
Type of error
Typo
Location of the error
https://marabos.nl/atomics/memory-ordering.html#relaxed
Description of the error
Mismatch between code:
X.fetch_add(5, Relaxed); X.fetch_add(10, Relaxed);
And text: ... only one possible order of modification of X: 0→5→15. It starts at zero, then becomes five, and is finally changed to fifteen. Threads cannot observe any values from X that are inconsistent with this total modification order. This means that "0 0 0 0", "0 0 5 15", and "0 15 15 15" are some of the possible results from the print statement in the other thread, while an output of "0 5 0 15" or "0 0 10 15" is impossible.
Possible fix: Either change 10 to 15 in the code, or change the text: ... only one possible order of modification of X: 0→5→10. It starts at zero, then becomes five, and is finally changed to ten. Threads cannot observe any values from X that are inconsistent with this total modification order. This means that "0 0 0 0", "0 0 5 10", and "0 10 10 10" are some of the possible results from the print statement in the other thread, while an output of "0 5 0 10" or "0 0 10 15" is impossible.