I'm at the moment reading Concurrent Programming on Windows by Joe Duffy, and came across the following statement:
Multiple threads make private copies of data from a shared location
This statement was given after an example where Joe showed how incrementing a global variable from multiple threads could lead to unpredictable results, because they could overlap in time.
However I remain skeptic about the statement, since there's no such thing as a private copy of a atomic data type - that would make it non-atomic.
So when he says make private copies of data from a shared location is it then simply all non-atomic data types (user-defined types, etc.) he means, or have I missed something?
Since I don't have the book on hands, I can only guess he's talking about how processors execute code.
There is no scape from transferring data to a CPU register because this is the only way a CPU instruction can access it. So, in this sense, every time a thread uses data from a shared location a temporary private copy has to be made.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With