[cpp-threads] Somewhat relevant technical report

Hans Boehm Hans.Boehm at hp.com
Sat Dec 17 18:39:49 GMT 2005



On Sat, 17 Dec 2005, Peter Dimov wrote:

> Boehm, Hans wrote:
> > I think we're trying to say different things, and perhaps the footnote
> > should be rephrased.
> >
> > We basically have, in Posix terms:
> >
> > T1: v1 = 1; pthread_mutex_lock(&l1);
> >
> > T2: pthread_mutex_trylock(&l1) fails; r2 = v1;
> >
> > The question is whether r2 is guaranteed to be 1.
> >
> > As I see it, the only reason this might not be guaranteed is that
> > pthread_mutex_try_lock doesn't guarantee memory synchronization in
> > this case.
> >
> > It's unclear what that statement means.
>
> To me it means exactly what it says. A failed pthread_mutex_trylock is a
> no-op with respect to memory synchronization and visibility, a { return
> false; }.
>
And then the resulting program has no data races, but insufficient
"memory synchronization".  I'm not sure I know what the resulting
semantics are.

In any case, the extra lock-unlock pair still gets us back to something
that both has no data races and sufficient memory syncronization.

Hans



More information about the cpp-threads mailing list