Author: Daniel Clausen
Date: 01:26:42 11/08/02
Go up one level in this thread
On November 07, 2002 at 19:06:06, Murray wrote: [snip] >But imagine if two threads could be executing that code. One might increment a >from 9 to 10, and IMMEDIATELY the other thread might increment a from 10 to >11, and the first one then tests if a == 10 and it fails, and the second one >tests if a == 10 and it fails. Just a minor issue, but the test (++a == 10) is not necessarily done like how you describe it, at least not in ANSI-C. ANSI-C merely guarantees that the increment of 'a' will be performed before the next sequence point. So technically, the value 'a+1' is used in the comparision and 'a' is incremented somewhere before the whole statement is finished. (that's not a big issue here, but it explains why things like 'a=a++' are undefined) Of course race conditions like you describe can still happen. Sargon
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.