[cpp-threads] D2335 (sequential consistency proof) revision
Lawrence Crowl
Lawrence at Crowl.org
Fri Aug 24 23:01:20 BST 2007
On 8/24/07, Boehm, Hans <hans.boehm at hp.com> wrote:
> > From: Lawrence Crowl
> > The reasoning is that if SC is a strong goal, then we need to
> > provide the mechanisms to make it achievable. An alternate
> > approach is to disallow this use of the trylock.
> >
> Here's another possible way out of this. I'm not 100% sure this is
> correct yet, but it seems like it on first glance:
>
> We allow trylock and timedlock to fail spuriously, even if the lock was
> never held.
Specifically, trylock may return "I did not lock" even though the
lock was free. (Spuriously locking when the lock was not free
would be ... bad.)
> This has no actual implementation impact, in that implementations that
> never fail spuriously are fine. The programmer is just not allowed to
> rely on that behavior. This is purely a way to characterize "bad" uses
> of trylock to the programmer.
The next task is to communicate the implications to programmers.
> If we do this, I believe we no longer need acquire semantics for a
> failed trylock. I think that also applies to Java, which is why it
> might be an attractive change there.
>
> Would everyone be OK with this?
It is okay with me. It certainly avoids expanding the lock interface,
which is probably a good thing.
--
Lawrence Crowl
More information about the cpp-threads
mailing list