An introduction to lockless algorithms
An introduction to lockless algorithms
Posted Mar 7, 2021 15:16 UTC (Sun) by jcm (subscriber, #18262)Parent article: An introduction to lockless algorithms
1. Happens before can be thought of as "if it happens". When there are two threads sharing a variable, and there is order through barriers or acquire/release, you're still checking the value of the shared variable. No thread waits for another, it's just that *if* you see an update to the shared variable, you're guaranteed that you also see all that came before. This article is quite good at pointing that out, but many others don't really highlight this part.
2. The difference between the smp_store_release/smp_load_acquire and the WRITE_ONCE/READ_ONCE with barriers is that the latter uses "full" barriers while the former can be thought of as using "half" barriers that only order in one direction for each half of the acquire/release pair, which allows certain other unrelated loads and stores to pass into/out of the critical section doing the shared variable update.