4 ms·
It absolutely is possible for a value to decrease, and that does not require reads or writes to not be atomic. Picture Thread A reading the value of X=0, then
by reitzensteinm 5y ago
It absolutely is possible for a value to decrease, and that does not require reads or writes to not be atomic.
Picture Thread A reading the value of X=0, then the Python scheduler preempts the thread. Then Thread B fetches and increments X three times. X is now 3. Thread A then runs again, and increments the value of X it had read previously, (0+1), then writes 1 to X.
The memory location just went: 0,1,2,3,1
I'm working on a series for my blog called Temporal Fuzzing that simulates these edge cases in a virtual machine. It is often very hard to predict the total set of possible behaviour given random interleavings.
https://www.reitzen.com/post/temporal-fuzzing-01/ https://www.reitzen.com/post/temporal-fuzzing-01/
- deleted 5y ago[deleted]