Title
Condition variable specification
Status
c++14
Section
[thread.condition]
Submitter
Hans Boehm

Created on 2012-09-25.00:00:00 last changed 130 months ago

Messages

Date: 2013-04-20.08:17:49

Proposed resolution:

This wording is relative to N3376.

  1. Change [thread.condition] p4 as indicated:

    -4- The implementation shall behave as if all executions of notify_one, notify_all, and each part of the wait, wait_for, and wait_until executions are executed in somea single unspecified total order consistent with the "happens before" order.

Date: 2013-04-15.00:00:00

[ 2013-04-20, Bristol ]

Accepted for the working paper

Date: 2012-11-02.22:48:46

[ 2012, Portland: Move to Review ]

This is linked to a glibc issue, and a POSIX specification issue.

We believe the proposed wording fixes the ambiguity in C++ and is compatible with the proposed resolution for Posix (which confirms the glibc behaviour as illegal).

Moved to review (Detlef hopes to send some improved wording to the reflector).

Date: 2012-09-25.00:00:00

The condition variable specification possibly leaves it unclear whether the effect of a notify_one() call can effectively be delayed, so that a call unblocks a wait() call that happens after the notify_one call. (For notify_all() this is not detectable, since it only results in spurious wake-ups.) Although this may at first glance seem like a contrived interpretation, it gains relevance since glibc in fact allows the analogous behavior (see here) and it is currently controversial whether this is correct and the Posix specification allows it (see here).

The following proposed resolution disallows the glibc implementation, remaining consistent with the believed intent of C++11. To make that clear, we require that the "unspecified total order" O from [thread.condition] p4 be consistent with happens-before. We also intend that the 3 components of a wait occur in order in O, but stating that explicitly seems too pedantic. Since they are numbered, it appears clear enough that they are sequenced one after the other.

Another uncertainty with the current phrasing is whether there is a single total order that includes all c.v. accesses, or one total order per c.v. We believe it actually doesn't matter, because there is no way to tell the difference, but this requires a bit more thought. We resolved it one way, just to remove the potential ambiguity.

History
Date User Action Args
2014-02-20 13:20:35adminsetstatus: wp -> c++14
2013-04-25 19:07:07adminsetstatus: voting -> wp
2013-04-20 08:17:49adminsetmessages: + msg6496
2013-04-20 08:17:49adminsetstatus: review -> voting
2012-11-02 22:48:46adminsetmessages: + msg6257
2012-11-02 22:48:46adminsetstatus: new -> review
2012-09-27 22:24:35adminsetmessages: + msg6146
2012-09-25 00:00:00admincreate