An Operational Semantics for C/C++11 Concurrency

被引:26
|
作者
Nienhuis, Kyndylan [1 ]
Memarian, Kayvan [1 ]
Sewell, Peter [1 ]
机构
[1] Univ Cambridge, Cambridge CB2 1TN, England
基金
英国工程与自然科学研究理事会;
关键词
C/C plus; Concurrency;
D O I
10.1145/3022671.2983997
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
The C/C++11 concurrency model balances two goals: it is relaxed enough to be efficiently implementable and (leaving aside the "thin-air" problem) it is strong enough to give useful guarantees to programmers. It is mathematically precise and has been used in verification research and compiler testing. However, the model is expressed in an axiomatic style, as predicates on complete candidate executions. This suffices for computing the set of allowed executions of a small litmus test, but it does not directly support the incremental construction of executions of larger programs. It is also at odds with conventional operational semantics, as used implicitly in the rest of the C/C++ standards. Our main contribution is the development of an operational model for C/C++11 concurrency. This covers all the features of the previous formalised axiomatic model, and we have a mechanised proof that the two are equivalent, in Isabelle/HOL. We also integrate this semantics with an operational semantics for sequential C (described elsewhere); the combined semantics can incrementally execute programs in a small fragment of C. Doing this uncovered several new aspects of the C/C++11 model: we show that one cannot build an equivalent operational model that simply follows program order, sequential consistent order, or the synchronises-with order. The first negative result is forced by hardware-observable behaviour, but the latter two are not, and so might be ameliorated by changing C/C++11. More generally, we hope that this work, with its focus on incremental construction of executions, will inform the future design of new concurrency models.
引用
收藏
页码:111 / 128
页数:18
相关论文
共 50 条
  • [1] An operational semantics for C/C++11 concurrency
    [J]. 2016, Association for Computing Machinery, 2 Penn Plaza, Suite 701, New York, NY 10121-0701, United States (51):
  • [2] Algebraic Semantics for C++11 Memory Model
    Xiao, Lili
    Zhu, Huibiao
    He, Mengda
    Qin, Shengchao
    [J]. 2022 IEEE 46TH ANNUAL COMPUTERS, SOFTWARE, AND APPLICATIONS CONFERENCE (COMPSAC 2022), 2022, : 1513 - 1518
  • [3] Clarifying and Compiling C/C++ Concurrency: from C++11 to POWER
    Batty, Mark
    Memarian, Kayvan
    Owens, Scott
    Sarkar, Susmit
    Sewell, Peter
    [J]. ACM SIGPLAN NOTICES, 2012, 47 (01) : 509 - 520
  • [4] Clarifying and Compiling C/C plus plus Concurrency: from C++11 to POWER
    Batty, Mark
    Memarian, Kayvan
    Owens, Scott
    Sarkar, Susmit
    Sewell, Peter
    [J]. POPL 12: PROCEEDINGS OF THE 39TH ANNUAL ACM SIGPLAN-SIGACT SYMPOSIUM ON PRINCIPLES OF PROGRAMMING LANGUAGES, 2012, : 509 - 520
  • [5] Mixed-Size Concurrency: ARM, POWER, C/C++11, and SC
    Flur, Shaked
    Sarkar, Susmit
    Pulte, Christopher
    Nienhuis, Kyndylan
    Maranget, Luc
    Gray, Kathryn E.
    Sezgin, Ali
    Batty, Mark
    Sewell, Peter
    [J]. ACM SIGPLAN NOTICES, 2017, 52 (01) : 429 - 442
  • [6] Mixed-size concurrency: ARM, POWER, C/C++11, and SC
    Flur, Shaked
    Sarkar, Susmit
    Pulte, Christopher
    Nienhuis, Kyndylan
    Maranget, Luc
    Gray, Kathryn E.
    Sezgin, Ali
    Batty, Mark
    Sewell, Peter
    [J]. ACM SIGPLAN Notices, 2017, 52 (01): : 429 - 442
  • [7] Automatic Checking of the Usage of the C++11 Move Semantics
    Barath, Aron
    Porkolab, Zoltan
    [J]. ACTA CYBERNETICA, 2015, 22 (01): : 5 - 20
  • [8] C++11 in Parallel
    Hummel, Joseph E.
    [J]. SIGCSE 12: PROCEEDINGS OF THE 43RD ACM TECHNICAL SYMPOSIUM ON COMPUTER SCIENCE EDUCATION, 2011, : 656 - 656
  • [9] Repairing Sequential Consistency in C/C++11
    Lahav, Ori
    Vafeiadis, Viktor
    Kang, Jeehoon
    Hur, Chung-Kil
    Dreyer, Derek
    [J]. ACM SIGPLAN NOTICES, 2017, 52 (06) : 618 - 632
  • [10] Preparing for the new C++11 standard
    Naumann, Axel
    [J]. INTERNATIONAL CONFERENCE ON COMPUTING IN HIGH ENERGY AND NUCLEAR PHYSICS 2012 (CHEP2012), PTS 1-6, 2012, 396