[cpp-threads] infinite loops

Herb Sutter hsutter at microsoft.com
Mon Jul 31 17:52:09 BST 2006


Doug wrote:
> Peter Dimov wrote:
> > In other words, your proposed rule is that if
> >
> > something; something; something; ...; something; x = 42;
> >
> > can be transformed to
> >
> > x = 42; something; something; something; ...; something;
> >
> > for any finite amount of somethings, then it is allowed even when
the
> > actual amount of iterations may be infinite.
> 
> Yes, exactly so. Thanks for saying this more clearly than I did :-)

Hmm. That's interesting, because I thought the main issue with
nonterminating loops was that moving x=42; up could cause a write to
happen that could never happen in any SC execution. In particular, the
canonical example is "what if the lock protecting x is taken iff the
loop doesn't terminate"?

I happen to agree that this is a corner case where I'm not very worried
about the "moving the assignment up can create a race" specter, but I
don't think that the above addresses this, does it?

Also, doesn't the above need to say something about the loop containing
only ordinary reads and writes (or was that assumption implicit or
mentioned in some earlier email)?

Herb




More information about the cpp-threads mailing list