Load N 6. Increment stack copy 8. After Step 4, the value of N will be reset to 1, and Process 2 loads this value in the next step. Process 1 repeatedly increments N in Step 6, but Process 2 retains the value 1 in its stack for a final increment and store. Note that we can easily generalize this scenario to an arbitrary number of processes.
Intuition is a poor guide for analyzing the behavior of concurrent programs.
A. Burns and G. Davies, Concurrent Programming, Addison-Wesley, Reading, Mass., 1993. Inc. All rights resserved.