?

Log in

No account? Create an account

Previous Entry | Next Entry

So you want to be a software developer?

We live in interesting times. The free lunch we got from Moore's Law is over. So we all have to program with concurrency in mind.

No big deal? Consider the fact that most of C++'s standard smart pointers still don't support atomic writes. Not Boost's (documentation), not Loki's (despite an MT ownership policy) not Scott Meyers's. What's that mean?

shared_ptr p(new int(42));

// thread A (supposedly owning)
p = shared_ptr(new int(1942));      // re-writes p

// thread B (supposedly reading)
{
    shared_ptr p2(p);
}

What otherwise looks like one thread owning the resource and another thread inspecting it, is actually undefined behavior.

Herb Sutter and Andrei Alexandrescu have written complex multi-part articles in the C/C++ User's Journal addressing variants of the issue, and almost always with corrections the next month. It's a topic almost impossible to get right.

The current state of the art seems to be led by Joe Seigh with his atomic_ptr. Apparently similar to patent 20060037026.

An "introductory" article can be found in the December 2004 issue of the CUJ, Atomic Reference Counting Pointers by William K. Reinholz.

Comments

( 1 comment — Leave a comment )
sjonsvenson
Mar. 21st, 2006 09:14 pm (UTC)
We don't have to go back to assembler for getting speed.
Not yet.
( 1 comment — Leave a comment )