David (dblume) wrote,

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.
Tags: programming

  • Tron and the Realm of Fantastic Opportunity

    Around 1982, I was a teenager working off-the-books at the local arcade. I took out the trash, cleaned the front windows, the bathroom, and the…

  • She Rolls Brains (Father's Day Edition)

    The way Tycho Brahe rolls twenties, my wife rolls brains. It's unbelievable. She's undefeated in Zombie Dice, so far. Zombie Dice? Yeah, that's one…

  • Wonderful Early Father's Day

    We've got some neighborhood commitments on Father's Day, so my family decided to celebrate an early Father's Day today, just for me. My one…

  • Post a new comment


    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 1 comment