> > the difference, and my main point is that the loop in ainc means
> > that it is not a wait-free algorithm.  this is not only sub optimal,
> > but also could lead to incorrect behavior.
> 
> I think a more likely possibility for the change is to have a
> *copy* of what was incremented. lock incl 0(ax) won't tell you
> what the value was when it was incremented.

you can read the code.  that value is not used by the thread library.

> But I don't see how the change will lead to an incorrect behavior.

could.

imagine you have two threads entering ainc.  the loser will
loop.  imagine that before the loser completes his loop a
third thread enters aintr and becomes a two-time loser.  by
induction it's possible that the loser never completes in n
loops for any given n.

this of course is basically the definition of a waiting algorithm.

if your program depends on time-bounded behavior from
the thread library, you could have trouble with a non-wait-free
algorithm like this.

perhaps my concern is unfounded.  i'd like to hear the argument.

- erik

Reply via email to