Slides for tomorrow night
Hans Boehm
Hans.Boehm at hp.com
Tue Oct 19 05:02:32 BST 2004
Andrei -
I didn't receive the attachment.
Hans
On Mon, 18 Oct 2004, Andrei Alexandrescu wrote:
> > Slide 5 and 6: I think this isn't quite accurate. Generally reads
> > and writes can't be moved across the lock because lock
> > implementations are carefully designed to make them opaque to the
> > compiler.
>
> Yes, but the language has no notion of opaque, which is what a
> standardization committee deals with. But yes, point taken. I changed
> the slides to gloss over the issue in a different way :o). I've reread
> your example (after optimization):
>
> r = x;
> for (...) {
> if (...) { x = r; pthread_mutex_lock(...); r = x; }
> r = ... r ...
> if (...) { x = r; pthread_mutex_unlock(...); r = x; }
> }
> x = r;
>
> and I will talk about it if anyone asks.
>
> > Slide 8: My impression is that even if both are volatile, the
> > official pthreads position is that volatile has nothing to do with
> > thread visibility, and therefore you get no gurantees.
>
> True. The issue is what the standard says, and it does say that the
> sequence is preserved. On the other hand, it also says that the
> semantics of "observing" a volatile variable are up to the
> implementation. So there's not much of a guarantee there.
>
> Pthreads wisely chose to stay away from volatile's
> insufficiently-defined semantics.
>
> I attach a modified deck of slides incorporating most of the good
> suggestions that I've gotten. Thanks, and let me know of any more. I
> guess I'll have some more time before the meeting.
>
>
> Andrei
>
More information about the cpp-threads
mailing list