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.

220<br />

in composition with a client will be a subset of that of the other. From this observation,<br />

we define a sound abstraction relation over histories that we can then lift to the sets of<br />

histories generated by library code.<br />

With this formulation of abstraction, a specification is simply a collection of histories.<br />

Here, our implementation <strong>and</strong> specification are both programs, <strong>and</strong> we will enumerate<br />

the histories of each by executing them in an arbitrary client context. This motivates the<br />

definition of the most general client: rather than enumerate the behaviour of the library<br />

in an arbitrary client context, we would like a constrained set of client contexts that are<br />

sufficient to generate all possible histories. <strong>The</strong> most general client must enumerate all<br />

possible combinations of library calls, on any number of threads, with all possible values<br />

of arguments. <strong>The</strong> definition of the most general client is:<br />

Definition 18. <strong>The</strong> most general client is defined as follows: Take n ≥ 1 <strong>and</strong> let<br />

{m 1 ,...,m l } be the methods implemented by a library L. We let<br />

MGC n (L) = (let L in C mgc<br />

1 ‖ ... ‖ C mgc<br />

n ),<br />

where C mgc<br />

t<br />

is<br />

while(nondet()) { if(nondet()) {m 1 }else if(nondet()) {m 2 } ... else {m l } }<br />

Here, we let the parameters of library methods be chosen arbitrarily.<br />

Weareconsideringarestrictedsetofprogramswherealllibrarylocationsareinitialised<br />

with writes that happen before all other memory accesses. We write LI for the set of<br />

executions of the library L under the most general client starting from an initial state<br />

I.<br />

To cover the set of all possible consistent executions, we must also enumerate all<br />

possible client happens-before edges: the presence of a client happens-before edge does<br />

not simply restrict the set of consistent executions; it can introduce new ones, by creating<br />

a new visible-side-effect for a non-atomic read, allowing a new value to be read, for<br />

example. We define the extension of an execution X with the relation R as an execution<br />

with identical components whose happens-before relation is transitively extended with R.<br />

Now we can extend the execution of the most general client with an arbitrary set of client<br />

happens-before edges so that we capture all possible behaviours of the library. We write<br />

L,RI for the set of consistent executions of L from I extended with R.<br />

In Lemma 22 we establish the following: all library projections of an execution of a<br />

client <strong>and</strong> a library are contained in the execution of the library under the most general<br />

client, extended with client happens-before edges. This shows that the MGC can<br />

reproduce the behaviour of the library under any client, <strong>and</strong> that it is, in fact, most<br />

general.

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

Saved successfully!

Ooh no, something went wrong!