Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Lockfree Programming: A Mental Model.
I think the example code in section "4. Reordering" would be stronger if one of the two threads had their order of operations switched, e.g.:
void thread_2() { printf("value_2: %d\n", *ptr_to_shared_2); printf("value_1: %d\n", *ptr_to_shared_1); }
value_2: 1 value_1: 0
There are no comments on this comment yet.
I think the example code in section "4. Reordering" would be stronger if one of the two threads had their order of operations switched, e.g.:
That way, when you see: You know reordering must have happened. As it stands, no reordering is necessary -- it could simply be that both writes took effect at thread 2 in-order, but with the write to *ptr_to_shared_1 taking effect after the first print statement.