Quantcast
Channel: The Old New Thing
Viewing all articles
Browse latest Browse all 24428

re: This code would be a lot faster if it weren't for the synchronization

$
0
0

> Thread A can be interrupted by timer expirations after its read but before its write.  In the meantime, while Thread A is suspended, Thread B can read the (old) value (that has not been incremented by Thread A), increment it, and write it back.  Then Thread A is dispatched again, when it writes its incremented value back from its own copy.  

How did you split the assembly instruction inc [address], which is what my compiler generates for increment?

[Your analysis may be true for a single instruction on a uniprocessor system, but in the general case, the operations are multi-instruction. -Raymond]

Viewing all articles
Browse latest Browse all 24428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>