Skip to main content
QUICK REVIEW

[论文解读] Operational Aspects of C/C++ Concurrency

Anton Podkopaev, Ilya Sergey|arXiv (Cornell University)|Jun 4, 2016
Parallel Computing and Optimization TechniquesComputer Science参考文献 34被引用 9
一句话总结

本文提出了一种新颖的、可执行的 C/C++11 并发操作语义,基于两个核心组件:用于建模线程特定内存视图的视图边界(viewfronts),以及用于捕捉宽松原子操作中推测性重排序的操作缓冲区(operation buffers)。该框架统一地建模了所有 C11 同步原语——包括释放/获取、顺序一致性以及宽松原子操作——同时防止了“凭空出现”(out-of-thin-air)的行为,并通过小测试程序和一个真实世界的 RCU 数据结构案例研究进行了验证。

ABSTRACT

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.

研究动机与目标

  • 为完整的 C/C++11 内存模型提供一种统一的、可执行的操作语义,包括所有同步原语。
  • 通过视图边界和操作缓冲区,建模并发执行的空间和时间特性——具体而言,即线程可观察到的值及其观察顺序。
  • 通过精心设计操作缓冲区及其嵌套结构,防止“凭空出现”(OTA)行为,即值在无来源的情况下出现。
  • 通过支持逐步执行和执行轨迹重建,为程序分析、测试和调试提供可执行的语义。
  • 通过提供程序逻辑和符号分析的基础,支持组合式推理与验证。

提出的方法

  • 引入视图边界作为线程特定的、一致的每位置内存历史视图,类似于分布式系统中的向量时钟。
  • 使用操作缓冲区来建模宽松原子操作的推测性重排序,其嵌套结构可处理条件性推测。
  • 从一个抽象状态机开始,逐步构建一系列逐渐细化的操作语义,逐步引入 C11 的各项特性。
  • 使用 PLT Redex 实现该语义,支持小测试程序和真实程序的执行、测试和轨迹生成。
  • 通过确保所有观察到的值在执行历史中均有有效来源,从而强制保证正确性,阻止“凭空出现”行为。
  • 支持面向切面的配置,允许选择性地启用/禁用 C11 特性,以实现模块化推理。

实验结果

研究问题

  • RQ1如何在一个统一框架中建模所有 C11 同步机制——包括释放/获取、顺序一致性以及宽松原子操作?
  • RQ2如何形式化地捕捉宽松原子操作中的推测执行和重排序,同时不引入“凭空出现”行为?
  • RQ3视图边界和操作缓冲区能否结合使用,以同时建模并发的时空特性——即线程所见内容(空间)和结果被观察的时间顺序(时间)?
  • RQ4如何使此类语义可执行,并可用于真实并发程序的测试与调试?
  • RQ5该语义能否扩展以支持编译到 ARM 和 POWER 等低级架构?

主要发现

  • 该框架成功在一个统一、统一的操作模型中建模了所有关键的 C11 并发特性,包括消费读取(consume-reads)和宽松原子操作。
  • 通过规范地处理操作缓冲区,该语义确保所有观察到的值均有有效的因果来源,从而防止了“凭空出现”行为。
  • 在 PLT Redex 中的实现支持执行和轨迹生成,这些被用于通过小测试程序语料库验证该语义。
  • 该原型成功检测到一个真实世界 Read-Copy-Update(RCU)数据结构中的同步错误,并提供了可重现的执行轨迹。
  • 该方法支持组合式推理,可扩展至高阶程序逻辑和验证框架。
  • 与需要对每次读操作进行指数级状态探索的先前基于事件结构的语义相比,该模型更具实用性。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。