Top


定義場所(file name)

hotspot/src/share/vm/prims/jvmtiRawMonitor.cpp

説明(description)

// Used for JVMTI raw monitor implementation.
// All JavaThreads will enter here with state _thread_blocked

名前(function name)

int JvmtiRawMonitor::raw_wait(jlong millis, bool interruptible, TRAPS) {

本体部(body)

  {- -------------------------------------------
  (1) (トレース出力)
      ---------------------------------------- -}

      TEVENT (raw_wait) ;

  {- -------------------------------------------
  (1) カレントスレッドがロックを持っていなければ, ここでリターン (OM_ILLEGAL_MONITOR_STATE).
      ---------------------------------------- -}

      if (THREAD != _owner) {
        return OM_ILLEGAL_MONITOR_STATE;
      }

  {- -------------------------------------------
  (1) 
      ---------------------------------------- -}

      // To avoid spurious wakeups we reset the parkevent -- This is strictly optional.
      // The caller must be able to tolerate spurious returns from raw_wait().
      THREAD->_ParkEvent->reset() ;
      OrderAccess::fence() ;

      // check interrupt event
      if (interruptible && Thread::is_interrupted(THREAD, true)) {
        return OM_INTERRUPTED;
      }

      intptr_t save = _recursions ;
      _recursions = 0 ;
      _waiters ++ ;
      if (THREAD->is_Java_thread()) {
        guarantee (((JavaThread *) THREAD)->thread_state() == _thread_blocked, "invariant") ;
        ((JavaThread *)THREAD)->set_suspend_equivalent();
      }
      int rv = SimpleWait (THREAD, millis) ;
      _recursions = save ;
      _waiters -- ;

      guarantee (THREAD == _owner, "invariant") ;
      if (THREAD->is_Java_thread()) {
         JavaThread * jSelf = (JavaThread *) THREAD ;
         for (;;) {
            if (!jSelf->handle_special_suspend_equivalent_condition()) break ;
            SimpleExit (THREAD) ;
            jSelf->java_suspend_self();
            SimpleEnter (THREAD) ;
            jSelf->set_suspend_equivalent() ;
         }
      }
      guarantee (THREAD == _owner, "invariant") ;

      if (interruptible && Thread::is_interrupted(THREAD, true)) {
        return OM_INTERRUPTED;
      }
      return OM_OK ;
    }

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.