29.11.2015 Views

The C11 and C++11 Concurrency Model

1ln7yvB

1ln7yvB

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

19<br />

of memory orders for fine-grained control over the ordering of memory accesses. <strong>The</strong><br />

C/<strong>C++11</strong> memory model allows a superset of the relaxed behaviour allowed by its target<br />

architectures. Bychoosingstrongermemoryorders, onecanforbidthisrelaxedbehaviour.<br />

1.1 Focus of this thesis<br />

<strong>The</strong> C <strong>and</strong> C++ memory models are defined by the International St<strong>and</strong>ards Organisation<br />

(ISO) in two lengthy st<strong>and</strong>ard documents [30, 8]. Prior to my work, there were<br />

drafts describing the C/<strong>C++11</strong> memory model, but those drafts, despite careful crafting<br />

by experts, were not known to describe a usable language memory model. <strong>The</strong> prose<br />

specifications were untestable, <strong>and</strong> the model was not well understood. It was not formally<br />

established whether the design was implementable, programmable, concise, or even<br />

internally consistent, nor had the central design tenets, laid out early in the design process<br />

[38, 35] <strong>and</strong> reiterated by Boehm <strong>and</strong> Adve [37], been established.<br />

In my work, I have sought to underst<strong>and</strong> the C/<strong>C++11</strong> memory model in formal<br />

terms, to fix parts that were broken, to prove that the design is usable, <strong>and</strong>, where fixing<br />

problems was not yet possible, to highlight outst<strong>and</strong>ing issues. In this thesis I assess the<br />

C/<strong>C++11</strong>memorymodeldesign, presentingaclear <strong>and</strong>completepictureofamainstream<br />

programming-language relaxed memory model. This effort both improved the C/<strong>C++11</strong><br />

definition <strong>and</strong> can inform the design of future programming-language memory models.<br />

1.2 Contributions<br />

Chapter 3 describes a formal version of the C/<strong>C++11</strong> memory model that was developed<br />

in close contact with the st<strong>and</strong>ardisation committee. Work on this model fed corrections<br />

back to the language specification, <strong>and</strong> as a consequence, it is very closely in tune with<br />

the intention of the committee, <strong>and</strong> the ratified prose specification. <strong>The</strong> formal model is<br />

written in the specification language Lem [85, 90], <strong>and</strong> is readable, precise <strong>and</strong> executable<br />

(thefulldefinitionsareprovidedinAppendixC).<strong>The</strong>featuresofthemodelareintroduced<br />

in stages through a series of cut-down models that apply to programs that do not use all<br />

of the language features. This chapter also presents a simplified model omits a redundant<br />

part of the specification. This work was developed in discussion with Scott Owens, Susmit<br />

Sarkar, <strong>and</strong> Peter Sewell, but I played the leading role. It was published in POPL in<br />

2011 [28].<br />

Chapter 4 describes Cppmem, a tool that takes very small programs <strong>and</strong> calculates<br />

all of the behaviours allowed by the memory model. Cppmem is joint work with Scott<br />

Owens, Jean Pichon, Susmit Sarkar, <strong>and</strong> Peter Sewell. I contributed to the initial design<br />

of the tool, <strong>and</strong> the tool uses an automatic OCaml translation of my formal memory<br />

model produced by Lem. Cppmem is invaluable for exploring the behaviour of the mem-

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!