• Home
  • Welcome to the Jungle
  • Elements of Modern C++ Style
  • About

Sutter’s Mill

Herb Sutter on software, hardware, and concurrency

Feeds:
Posts
Comments
« Let’s Be Thoughtful Out There
GotW #88: A Candidate For the “Most Important const” »

Effective Concurrency: Use Lock Hierarchies to Avoid Deadlock

2007-12-11 by Herb Sutter

The latest Effective Concurrency column, "Use Lock Hierarchies to Avoid Deadlock", just went live on DDJ’s site, and will also appear in the print magazine. From the article:

… The only way to eliminate such a potential deadlock is to make sure that all mutexes ever held at the same time are acquired in a consistent order. But how can we ensure this in a way that will be both usable and correct? For example, we could try to figure out which groups of mutexes might ever be held at the same time, and then try to define pairwise ordering rules that cover each possible combination. But that approach by itself is prone to accidentally missing unexpected combinations of locks; and even if we did it perfectly, the result would still be at best "DAG spaghetti"—a directed acyclic graph (DAG) that nobody could comprehend as a whole. And every time we want to add a new mutex to the system, we would have to find a way fit it into the DAG without creating any cycles.

We can do better by directly exploiting the knowledge we already have about the structure of the program to regularize the mess and make it understandable. …

I hope you enjoy it.
Finally, here are links to previous Effective Concurrency columns (based on the dates they hit the web, not the magazine print issue dates):
July 2007 The Pillars of Concurrency
August 2007 How Much Scalability Do You Have or Need?
September 2007 Use Critical Sections (Preferably Locks) to Eliminate Races
October 2007 Apply Critical Sections Consistently
November 2007 Avoid Calling Unknown Code While Inside a Critical Section

Posted in Concurrency |

  • Tweets

    • GotW #5: Overriding Virtual Functions: Virtual functions are a pretty basic feature, but they occasionally har... bit.ly/14oTLHx 1 day ago
    • GotW #4: Class Mechanics: How good are you at the details of writing classes? This item focuses not only on bl... bit.ly/16Fqug8 1 day ago
    • GotW #4: Class Mechanics (7/10): How good are you at the details of writing classes? This item focuses not onl... bit.ly/10TmyVQ 5 days ago
    Follow @herbsutter
  • Popular

    • GotW #4 Solution: Class Mechanics
    • GotW #5: Overriding Virtual Functions
    • GotW #3 Solution: Using the Standard Library (or, Temporaries Revisited)
  • Categories

    • Apple
    • C# / .NET
    • C++
    • Cloud
    • Concurrency
    • Effective Concurrency
    • Friday Thoughts
    • GotW
    • Hardware
    • Java
    • Microsoft
    • Opinion & Editorial
    • Reader Q&A
    • Software Development
    • Talks & Events
    • Uncategorized
    • Web

Blog at WordPress.com.

Theme: Customized MistyLook by WPThemes.


Follow

Get every new post delivered to your Inbox.

Join 1,403 other followers

Powered by WordPress.com