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.

58<br />

| Blocked rmw l → lk l = Atomic<br />

end<br />

Some actions block forever, <strong>and</strong> the thread-local semantics must generate preexecutions<br />

in which permanently blocked actions have no successors in sequenced-before<br />

on the same thread:<br />

let blocking observed actions sb =<br />

(∀ a ∈ actions.<br />

(is blocked rmw a ∨ is blocked lock a)<br />

−→<br />

¬ (∃ b ∈ actions. (a, b) ∈ sb))<br />

<strong>The</strong> st<strong>and</strong>ard says that functions are ordered with respect to all other actions on the<br />

same thread by sequenced-before, whether or not an order is imposed by the syntax of<br />

the program; their sequencing is described as indeterminate (see Appendix A for the<br />

rationale). All memory accesses on atomic <strong>and</strong> mutex locations are the result of calls to<br />

library functions, <strong>and</strong> as a consequence, they are ordered with respect to all other actions<br />

on the same thread by sequenced before. This property is captured by the following<br />

conjunct of the well-formed-threads predicate:<br />

let indeterminate sequencing Xo =<br />

∀ a ∈ Xo.actions b ∈ Xo.actions.<br />

(tid of a = tid of b) ∧ (a ≠ b) ∧<br />

¬ (is at non atomic location Xo.lk a ∧ is at non atomic location Xo.lk b) −→<br />

(a, b) ∈ Xo.sb ∨ (b, a) ∈ Xo.sb<br />

We do not model the creation <strong>and</strong> joining of threads explicitly. Instead, the threadlocal<br />

semantics provides us with the additional synchronises-with relation, that captures<br />

parent-to-child thread creation ordering. <strong>The</strong> calculated relation sbasw is the transitive<br />

closure of the union of sb <strong>and</strong> asw. This relation captures program order <strong>and</strong> the interthread<br />

ordering induced by creating <strong>and</strong> joining threads. We require this relation to be<br />

acyclic.<br />

let sbasw Xo = transitiveClosure (Xo.sb ∪ Xo.asw)<br />

In addition to the requirements above, well formed threads predicate provides the following<br />

guarantees: all actions have a unique identifier (we require the projection of the<br />

action identifier to be injective), the sb <strong>and</strong> asw relations only relate actions of the execution,<br />

the sb relation must only relate actions on the same thread, the asw relation<br />

must only relate actions on different threads, the sb <strong>and</strong> dd relations are both strict partial<br />

orders, <strong>and</strong> the dd relation is a subset of the sb relation. <strong>The</strong> well formed threads<br />

predicate:

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

Saved successfully!

Ooh no, something went wrong!