Comment by vbsd Comment by vbsd 3 months ago 1 reply Copy Link View on Hacker News What sort of an interleaving would produce 1? Seems provably impossible to me, assuming atomic assignments.
Copy Link dtgriscom 2 months ago Collapse Comment - I took another look, and AFAICT you're right. The best I can do is get the value 2:* Run procedure P into its first iteration, stopping after temp is assigned "n + 1", or the value 1* Run procedure Q through nine iterations, stopping after the ninth has completed (n changes, but who cares?)* Run the next line of procedure P's first iteration, so that it assigns temp's value of 1 to n; n is now 1* Run procedure Q into its tenth iteration, stopping after temp is assigned the value 2* Complete procedure P (n changes, but who cares?)* Complete procedure Q, so that n is assigned the value of temp, or 2. Reply View | 0 replies
I took another look, and AFAICT you're right. The best I can do is get the value 2:
* Run procedure P into its first iteration, stopping after temp is assigned "n + 1", or the value 1
* Run procedure Q through nine iterations, stopping after the ninth has completed (n changes, but who cares?)
* Run the next line of procedure P's first iteration, so that it assigns temp's value of 1 to n; n is now 1
* Run procedure Q into its tenth iteration, stopping after temp is assigned the value 2
* Complete procedure P (n changes, but who cares?)
* Complete procedure Q, so that n is assigned the value of temp, or 2.