Defect Report #405

Previous Defect Report < - > Next Defect Report


Submitter: Batty
Submission Date: 2011-10-14
Source: WG 14
Reference Document: N1584
Version: 1.3
Date: April 2013
Subject: The mutex specification

Summary

The C11 specification of mutexes is missing the total order over all the calls on a particular mutex. This is present in C++11. The following is from 30.4.1.2p5 in N3291:
For purposes of determining the existence of a data race, these behave as atomic operations (1.10). The lock and unlock operations on a single mutex shall appear to occur in a single total order. [ Note: this can be viewed as the modification order (1.10) of the mutex. — end note ]
The synchronisation in 7.26.4 is defined in terms of some order over these calls, even though none is specified, for instance 7.26.4.4p2 reads:
Prior calls to mtx_unlock on the same mutex shall synchronize with this operation.
This seems like simple omission. We suggest adding a new paragraph to 7.26.4 that matches C++11:
For purposes of determining the existence of a data race, mutex calls behave as atomic operations. The lock and unlock operations on a single mutex shall appear to occur in a single total order.

NOTE: This can be viewed as the modification order of the mutex.

Suggested Technical Corrigendum

See above.
Oct 2011 meeting

Committee discussion

Feb 2012 meeting

Committee Discussion

Oct 2012 meeting

Committee Discussion

Add the following as 7.26.4 p1 and p2:
For purposes of determining the existence of a data race, lock and unlock operations behave as atomic operations. All lock and unlock operations on a particular mutex occur in some particular total order.

NOTE: This total order can be viewed as the modification order of the mutex.

Apr 2013 meeting

Committee Discussion

Accept wording from Oct 2012 as proposed technical corrigendum

Proposed Technical Corrigendum

Add the following as 7.26.4 p1 and p2:
For purposes of determining the existence of a data race, lock and unlock operations behave as atomic operations. All lock and unlock operations on a particular mutex occur in some particular total order.

NOTE: This total order can be viewed as the modification order of the mutex.

Previous Defect Report < - > Next Defect Report