April 14th, 2004 — Double-Checked Locking, Threads, Compiler Optimizations, and More — Scott Meyers

Published: Thu 01 April 2004
By nwcpp

In 2004.

Location

6464 185th Avenue NE
Redmond, WA 98052

Abstract

The Double-Checked Locking Pattern is a common approach to efficient lazy initialization. Unfortunately, it’s not reliable in threaded systems, it can fail for different reasons in uniprocessor and multiprocessor environments, and there’s no portable way to make it reliable. Every C++ programmer needs to understand why this is the case, because it affects the very core of software development: code generation and program execution. This presentation takes a deep look at code generation, compiler and hardware optimization, sequence points, “observable behavior,” the significance of “volatile,” cache coherency problems, and memory barriers. It concludes with suggestions for those who want the efficiency of lazy initialization, but who value correct program behavior even more.

Bio

Scott Meyers is one of the world’s foremost experts on C++ software development. He wrote the best-selling Effective C++ series (Effective C++, More Effective C++, and Effective STL); wrote and designed the innovative Effective C++ CD; is consulting editor for Addison Wesley’s Effective Software Development Series; and is a member of the advisory board for Software Development magazine. He also sits on technical advisory boards for several start-up companies. A programmer since 1972, he holds an M.S. in Computer Science from Stanford University and a Ph.D. from Brown University.

Click here to download the slides from the presentation