src/hotspot/os/posix/os_posix.cpp
changeset 59251 4cbfa5077d68
parent 59105 76ae9aa0e794
child 59252 623722a6aeb9
equal deleted inserted replaced
59250:a6deb69743d4 59251:4cbfa5077d68
  1996   // shake out uses of park() and unpark() without checking state conditions
  1996   // shake out uses of park() and unpark() without checking state conditions
  1997   // properly. This spurious return doesn't manifest itself in any user code
  1997   // properly. This spurious return doesn't manifest itself in any user code
  1998   // but only in the correctly written condition checking loops of ObjectMonitor,
  1998   // but only in the correctly written condition checking loops of ObjectMonitor,
  1999   // Mutex/Monitor, Thread::muxAcquire and JavaThread::sleep
  1999   // Mutex/Monitor, Thread::muxAcquire and JavaThread::sleep
  2000 
  2000 
  2001   if (Atomic::xchg(1, &_event) >= 0) return;
  2001   if (Atomic::xchg(&_event, 1) >= 0) return;
  2002 
  2002 
  2003   int status = pthread_mutex_lock(_mutex);
  2003   int status = pthread_mutex_lock(_mutex);
  2004   assert_status(status == 0, status, "mutex_lock");
  2004   assert_status(status == 0, status, "mutex_lock");
  2005   int anyWaiters = _nParked;
  2005   int anyWaiters = _nParked;
  2006   assert(anyWaiters == 0 || anyWaiters == 1, "invariant");
  2006   assert(anyWaiters == 0 || anyWaiters == 1, "invariant");
  2044 
  2044 
  2045   // Optional fast-path check:
  2045   // Optional fast-path check:
  2046   // Return immediately if a permit is available.
  2046   // Return immediately if a permit is available.
  2047   // We depend on Atomic::xchg() having full barrier semantics
  2047   // We depend on Atomic::xchg() having full barrier semantics
  2048   // since we are doing a lock-free update to _counter.
  2048   // since we are doing a lock-free update to _counter.
  2049   if (Atomic::xchg(0, &_counter) > 0) return;
  2049   if (Atomic::xchg(&_counter, 0) > 0) return;
  2050 
  2050 
  2051   Thread* thread = Thread::current();
  2051   Thread* thread = Thread::current();
  2052   assert(thread->is_Java_thread(), "Must be JavaThread");
  2052   assert(thread->is_Java_thread(), "Must be JavaThread");
  2053   JavaThread *jt = (JavaThread *)thread;
  2053   JavaThread *jt = (JavaThread *)thread;
  2054 
  2054