> 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]