Shared variables and data races in C++11

244
Опубликовано 28 июля 2016, 23:03
C++11 and C11 added threads to the respective languages. In the process they gave much more precise semantics to shared variables. Like a number of earlier standards, but unlike Java, these languages give semantics only to programs without data races. Compared to those earlier standards, they are much clearer on what that means, and remove the motivation for nonetheless writing code with data races. I will give an overview of the C++11 shared variable semantics or memory model, illustrate some of the subtleties around data races, and explain both why data race semantics were left undefined, and why, even in practice, it is never reasonable to rely on a C11 or C++11 program with data races. In particular, I will argue that programs with essentially all kinds of so-called "benign" data races are subject to future "miscompilation" by entirely reasonable compilers.
автотехномузыкадетское