Googles appar
Huvudmeny

Post a Comment On: cbloom rants

"05-30-12 - On C++ Atomic Fences"

7 Comments -

1 – 7 of 7
Blogger Unknown said...

Potentially silly question: what's "($)"?

May 31, 2012 at 12:14 PM

Blogger Fabian 'ryg' Giesen said...

That's a bit of Relacy magic to make the automatic enumeration of possible event orderings work.

May 31, 2012 at 1:29 PM

Blogger cbloom said...

Yeah, you can just pretend the $ is not there. It gets #define'd to different things for testing.

My own C++0x-look-alike atomic layer accepts the $ as an additional argument and does nothing with it, so that I can move code between Relacy and production without touching it.

(I also have an in-place Relacy-like test layer which uses real threads and real atomic ops, and in that case the $ does randomized thread switches and stalls to stress the code).

May 31, 2012 at 1:35 PM

Blogger Brian said...

I get the feeling that the C++ spec writers added fences more as an afterthought.

A nitpick... An acquire fence makes some preceding load act like a load_acquire (the immediately preceding load might not access the same memory address as a store_release ).

One thing I am curious about that the spec doesn't talk much about--- when is the compiler allowed to introduce a deadlock? Let's supposed that we have two threads that each publicize something and then wait for the other thread to publicize. The C++ spec isn't very clear on whether the compiler can reorder the load_acquires in the wait for publication loop above the store release.

May 31, 2012 at 4:27 PM

Blogger Brian said...

Guess that isn't quite right either since the synchronization happens at the fence and not preceding the load..

May 31, 2012 at 11:14 PM

Anonymous Anonymous said...

These posts are helpful. You should add them to your table of contents for low-level threading.

June 11, 2012 at 5:46 PM

Blogger cbloom said...

Word up. Made new TOC :

http://cbloomrants.blogspot.com/2012/06/06-12-12-another-threading-post-index.html

June 12, 2012 at 11:53 AM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.