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.Committee discussion
Feb 2012 meeting
- The quoted text was added to C++11 after WG 14 voted out the FDIS in London.
- The consensus was that this is probably an oversight, and should be changed along the lines that are recommended above.
Committee Discussion
Oct 2012 meeting
- The wording in the proposed wording is not correct, should read "shall occur" rather than "shall appear to occur."
- No consensus reached on the words, Clark Nelson took action item to furnish words for the next 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.Apr 2013 meetingNOTE: This total order can be viewed as the modification order of the mutex.
Committee Discussion
Accept wording from Oct 2012 as proposed technical corrigendumProposed 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.