Bojan Smojver wrote: > On Tue, 2009-06-09 at 10:58 -0500, William A. Rowe, Jr. wrote: >> You are not missing anything, and solutions are welcomed. > > I'm not sure that I'm addressing the right problem here. So, limit > yourself to rocks of no more than 2kg when throwing.
:) > Obviously, there is no guarantee that int's are atomic, so this patch > as-is is bogus. However, we have an atomic API in APR, so we can replace > the int's with apr_uint32_t, use that API to increment/decrement the > variables and also initialise it from apr_initialize() function, which > would then make sure it is available. > > Complete nonsense? No; this looks to be a very reasonable solution, depending on n++ is implemented in assembly code. Also remember in smp you might have two cpus potentially executing the code in lockstep. That said, this looks to significantly narrow the race, so +1 for 1.x!
