diff -r 3ab9867d7786 -r 381638db28e6 hotspot/src/os/linux/vm/os_linux.cpp --- a/hotspot/src/os/linux/vm/os_linux.cpp Thu Jul 03 09:16:56 2014 -0700 +++ b/hotspot/src/os/linux/vm/os_linux.cpp Thu Jul 03 11:07:51 2014 -0700 @@ -5457,22 +5457,12 @@ return abstime; } - -// Test-and-clear _Event, always leaves _Event set to 0, returns immediately. -// Conceptually TryPark() should be equivalent to park(0). - -int os::PlatformEvent::TryPark() { - for (;;) { - const int v = _Event; - guarantee((v == 0) || (v == 1), "invariant"); - if (Atomic::cmpxchg(0, &_Event, v) == v) return v; - } -} - void os::PlatformEvent::park() { // AKA "down()" // Invariant: Only the thread associated with the Event/PlatformEvent // may call park(). // TODO: assert that _Assoc != NULL or _Assoc == Self + assert(_nParked == 0, "invariant"); + int v; for (;;) { v = _Event; @@ -5572,8 +5562,7 @@ // 1 :=> 1 // -1 :=> either 0 or 1; must signal target thread // That is, we can safely transition _Event from -1 to either - // 0 or 1. Forcing 1 is slightly more efficient for back-to-back - // unpark() calls. + // 0 or 1. // See also: "Semaphores in Plan 9" by Mullender & Cox // // Note: Forcing a transition from "-1" to "1" on an unpark() means @@ -5801,10 +5790,9 @@ } void Parker::unpark() { - int s, status; - status = pthread_mutex_lock(_mutex); + int status = pthread_mutex_lock(_mutex); assert(status == 0, "invariant"); - s = _counter; + const int s = _counter; _counter = 1; if (s < 1) { // thread might be parked