Fix deSpinBarrier deadlock.
authorJarkko Pöyry <jpoyry@google.com>
Tue, 19 May 2015 03:55:41 +0000 (20:55 -0700)
committerJarkko Pöyry <jpoyry@google.com>
Tue, 19 May 2015 18:13:55 +0000 (11:13 -0700)
commite36eed77c8eaf42b32ebec458eb73682c5580f38
tree146715a4a7d20864d026981fa8b54379ec28e6fc
parent88b1dbc9f0d1ff6454c10a3b7f7f163fe21e95dd
Fix deSpinBarrier deadlock.

Detaching a thread from deSpinBarrier caused a race with spin barrier's
triggering thread (last thread: atomicInc(numEntered) == numThreads)
detection test. If numThreads was decremented during the triggering
thread test, another thread would also be classidfied as a trigger to
release the barrier.

Multiple concurrent "trigger" threads caused the spinbarrier state to
become corrupted.

This CL uses a cached numThreads value in trigger test which removes
the race with currently running trigger thread. This also removes
unnecessary m_numLeaving modifications.

Change-Id: Ibfb3d4925fbe3063c982440a555b8aa131544465
framework/delibs/decpp/deSpinBarrier.cpp