What's "sequentially consistent executions are free of data races"?

Viewed 1631

In JLS, §17.4.5. Happens-before Order, it says that

A program is correctly synchronized if and only if all sequentially consistent executions are free of data races.

It only give us definition about "sequentially consistent", it does not give us definition about "sequentially consistent executions". Only after knowing about what is "sequentially consistent executions", we may make further discussion about the topic.

So what's "sequentially consistent executions" and what's "sequentially consistent executions are free of data races"?

4 Answers

1) Sequential Consistent executions (by def.): the result of any execution is the same as if the operations of all the processors were executed in some sequential order, and the operations of each individual processor appear in this sequence in the order specified by its program

2) Data Race is a situation when concurrent operations accesses a shared memory location, of which at least one is a write.

3) So if the executions do not appear sequentially consistent their result will differ from the program result or would demonstrate the unexpected behavior. And such executions we don't want.

4) If to suppose that there is a seq. con. execution which is not free of a data race, then it means that there exists another fork of this seq. con. execution which reorders accesses in data race point and leads to the different program result. And then, these executions are not sequentially consistent with the program, or

5) the program allows seq. con. executions to have counterintuitive behaviors and unexpected results, and thus, is not correctly synchronized.

Related