3 ms·
> Use barriers. Many data-structures are safe if: > 1. Everyone is reading at the same time. > 2. Only one thread is writing to any particular location. I th
by paskozdilar 4y ago
> Use barriers. Many data-structures are safe if:
> 1. Everyone is reading at the same time.
> 2. Only one thread is writing to any particular location.
I think there is a missing point here:
3. Reads and writes do not happen at the same time.
- arka2147483647 4y agoIf rules 1. and 2. are followed, 3. is implicitly true
- paskozdilar 4y agoOh, right. If everyone is reading there is nobody left to write :) It seems like quite a restriction, though.
- dragontamer 4y agoSee: https://news.ycombinator.com/item?id=31480323 https://news.ycombinator.com/item?id=31480323 > The easiest way to understand 100,000 concurrent threads is by making all 100,000 threads do the same thing and execute the same code. If all your threads are off doing different things at different times, and executing different sets of code, you might have problems understanding your algorithm. Its a restriction for sure, but it does lead to far simpler "thinking". There's still a very rich space of parallel algorithms that can be explored within this restricted space. In effect: you probably *don't* want to write general-purpose "desynchronized" code unless you really have to. Keeping all 100,000 threads synchronized and in roughly the same spot of code really makes your brain think a lot easier.
- colinmhayes 4y agoHow can reads and writes happen at the same time if everyone is reading at the same time?