[Paper Review] Operational Aspects of C/C++ Concurrency
This paper presents a novel, executable operational semantics for C/C++11 concurrency based on two core components: viewfronts for modeling thread-specific views of memory and operation buffers for capturing speculative reordering in relaxed atomics. The framework uniformly models all C11 synchronization primitives—including release/acquire, sequentially consistent, and relaxed atomics—while preventing out-of-thin-air behaviors, and is validated through litmus tests and a real-world RCU data structure case study.
In this work, we present a family of operational semantics that gradually approximates the realistic program behaviors in the C/C++11 memory model. Each semantics in our framework is built by elaborating and combining two simple ingredients: viewfronts and operation buffers. Viewfronts allow us to express the spatial aspect of thread interaction, i.e., which values a thread can read, while operation buffers enable manipulation with the temporal execution aspect, i.e., determining the order in which the results of certain operations can be observed by concurrently running threads. Starting from a simple abstract state machine, through a series of gradual refinements of the abstract state, we capture such language aspects and synchronization primitives as release/acquire atomics, sequentially-consistent and non-atomic memory accesses, also providing a semantics for relaxed atomics, while avoiding the Out-of-Thin-Air problem. To the best of our knowledge, this is the first formal and executable operational semantics of C11 capable of expressing all essential concurrent aspects of the standard. We illustrate our approach via a number of characteristic examples, relating the observed behaviors to those of standard litmus test programs from the literature. We provide an executable implementation of the semantics in PLT Redex, along with a number of implemented litmus tests and examples, and showcase our prototype on a large case study: randomized testing and debugging of a realistic Read-Copy-Update data structure.
Motivation & Objective
- To provide a uniform, executable operational semantics for the full C/C++11 memory model, including all synchronization primitives.
- To model the spatial and temporal aspects of concurrent execution—specifically, which values threads can observe and in what order—using viewfronts and operation buffers.
- To prevent out-of-thin-air (OTA) behaviors, where values appear without a source, through careful design of operation buffers and their nesting.
- To enable practical program analysis, testing, and debugging by providing a semantics that supports step-by-step execution and trace reconstruction.
- To support compositional reasoning and verification by offering a foundation for program logics and symbolic analysis.
Proposed method
- Introduces viewfronts as thread-specific, consistent views of per-location memory histories, analogous to vector clocks in distributed systems.
- Employs operation buffers to model speculative reordering of relaxed atomic operations, with a nesting structure to handle conditional speculations.
- Constructs a family of gradually refined operational semantics starting from an abstract state machine, progressively incorporating C11 features.
- Uses PLT Redex to implement the semantics, enabling execution, testing, and trace generation for litmus tests and real programs.
- Enforces correctness by ensuring that all observed values have a valid source in the execution history, thus blocking OTA behaviors.
- Supports aspect-oriented configuration, allowing selective enabling/disabling of C11 features for modular reasoning.
Experimental results
Research questions
- RQ1How can a uniform operational semantics model all C11 synchronization mechanisms—release/acquire, sequentially consistent, and relaxed atomics—within a single framework?
- RQ2How can speculative execution and reordering in relaxed atomics be formally captured without introducing out-of-thin-air behaviors?
- RQ3Can viewfronts and operation buffers be combined to model both spatial (what a thread sees) and temporal (when results are observed) aspects of concurrency?
- RQ4How can such a semantics be made executable and usable for testing and debugging real concurrent programs?
- RQ5Can the semantics be extended to support compilation to low-level architectures like ARM and POWER?
Key findings
- The framework successfully models all essential C11 concurrency features, including consume-reads and relaxed atomics, in a single, uniform operational model.
- The semantics prevents out-of-thin-air behaviors through a disciplined treatment of operation buffers, ensuring all observed values have a valid causal origin.
- The implementation in PLT Redex enables execution and trace generation, which were used to validate the semantics against a corpus of litmus tests.
- The prototype successfully detected synchronization bugs in a real-world Read-Copy-Update (RCU) data structure, providing reproducible execution traces.
- The approach supports compositional reasoning and can be extended to higher-order program logics and verification frameworks.
- The model is more practical than prior event-structure-based semantics, which require exponential state exploration per read operation.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.