< prev index next >

src/hotspot/share/prims/jvmtiRawMonitor.cpp

Print this page




 356   void * List = _EntryList ;
 357   SimpleExit (THREAD) ;
 358 
 359   return OM_OK;
 360 }
 361 
 362 // Used for JVMTI raw monitor implementation.
 363 // All JavaThreads will enter here with state _thread_blocked
 364 
 365 int JvmtiRawMonitor::raw_wait(jlong millis, bool interruptible, TRAPS) {
 366   if (THREAD != _owner) {
 367     return OM_ILLEGAL_MONITOR_STATE;
 368   }
 369 
 370   // To avoid spurious wakeups we reset the parkevent -- This is strictly optional.
 371   // The caller must be able to tolerate spurious returns from raw_wait().
 372   THREAD->_ParkEvent->reset() ;
 373   OrderAccess::fence() ;
 374 
 375   // check interrupt event
 376   if (interruptible && Thread::is_interrupted(THREAD, true)) {



 377     return OM_INTERRUPTED;
 378   }

 379 
 380   intptr_t save = _recursions ;
 381   _recursions = 0 ;
 382   _waiters ++ ;
 383   if (THREAD->is_Java_thread()) {
 384     guarantee (((JavaThread *) THREAD)->thread_state() == _thread_blocked, "invariant") ;
 385     ((JavaThread *)THREAD)->set_suspend_equivalent();
 386   }
 387   int rv = SimpleWait (THREAD, millis) ;
 388   _recursions = save ;
 389   _waiters -- ;
 390 
 391   guarantee (THREAD == _owner, "invariant") ;
 392   if (THREAD->is_Java_thread()) {
 393      JavaThread * jSelf = (JavaThread *) THREAD ;
 394      for (;;) {
 395         if (!jSelf->handle_special_suspend_equivalent_condition()) break ;
 396         SimpleExit (THREAD) ;
 397         jSelf->java_suspend_self();
 398         SimpleEnter (THREAD) ;
 399         jSelf->set_suspend_equivalent() ;
 400      }
 401   }
 402   guarantee (THREAD == _owner, "invariant") ;
 403 
 404   if (interruptible && Thread::is_interrupted(THREAD, true)) {


 405     return OM_INTERRUPTED;

 406   }
 407   return OM_OK ;
 408 }
 409 
 410 int JvmtiRawMonitor::raw_notify(TRAPS) {
 411   if (THREAD != _owner) {
 412     return OM_ILLEGAL_MONITOR_STATE;
 413   }
 414   SimpleNotify (THREAD, false) ;
 415   return OM_OK;
 416 }
 417 
 418 int JvmtiRawMonitor::raw_notifyAll(TRAPS) {
 419   if (THREAD != _owner) {
 420     return OM_ILLEGAL_MONITOR_STATE;
 421   }
 422   SimpleNotify (THREAD, true) ;
 423   return OM_OK;
 424 }


 356   void * List = _EntryList ;
 357   SimpleExit (THREAD) ;
 358 
 359   return OM_OK;
 360 }
 361 
 362 // Used for JVMTI raw monitor implementation.
 363 // All JavaThreads will enter here with state _thread_blocked
 364 
 365 int JvmtiRawMonitor::raw_wait(jlong millis, bool interruptible, TRAPS) {
 366   if (THREAD != _owner) {
 367     return OM_ILLEGAL_MONITOR_STATE;
 368   }
 369 
 370   // To avoid spurious wakeups we reset the parkevent -- This is strictly optional.
 371   // The caller must be able to tolerate spurious returns from raw_wait().
 372   THREAD->_ParkEvent->reset() ;
 373   OrderAccess::fence() ;
 374 
 375   // check interrupt event
 376   if (interruptible) {
 377     assert(THREAD->is_Java_thread(), "Only JavaThreads can be interruptible");
 378     JavaThread* jt = (JavaThread*) THREAD;
 379     if (jt->is_interrupted(true)) {
 380       return OM_INTERRUPTED;
 381     }
 382   }
 383 
 384   intptr_t save = _recursions ;
 385   _recursions = 0 ;
 386   _waiters ++ ;
 387   if (THREAD->is_Java_thread()) {
 388     guarantee (((JavaThread *) THREAD)->thread_state() == _thread_blocked, "invariant") ;
 389     ((JavaThread *)THREAD)->set_suspend_equivalent();
 390   }
 391   int rv = SimpleWait (THREAD, millis) ;
 392   _recursions = save ;
 393   _waiters -- ;
 394 
 395   guarantee (THREAD == _owner, "invariant") ;
 396   if (THREAD->is_Java_thread()) {
 397      JavaThread * jSelf = (JavaThread *) THREAD ;
 398      for (;;) {
 399         if (!jSelf->handle_special_suspend_equivalent_condition()) break ;
 400         SimpleExit (THREAD) ;
 401         jSelf->java_suspend_self();
 402         SimpleEnter (THREAD) ;
 403         jSelf->set_suspend_equivalent() ;
 404      }
 405   }
 406   guarantee (THREAD == _owner, "invariant") ;
 407 
 408   if (interruptible) {
 409     JavaThread* jt = (JavaThread*) THREAD;
 410     if (jt->is_interrupted(true)) {
 411       return OM_INTERRUPTED;
 412     }
 413   }
 414   return OM_OK ;
 415 }
 416 
 417 int JvmtiRawMonitor::raw_notify(TRAPS) {
 418   if (THREAD != _owner) {
 419     return OM_ILLEGAL_MONITOR_STATE;
 420   }
 421   SimpleNotify (THREAD, false) ;
 422   return OM_OK;
 423 }
 424 
 425 int JvmtiRawMonitor::raw_notifyAll(TRAPS) {
 426   if (THREAD != _owner) {
 427     return OM_ILLEGAL_MONITOR_STATE;
 428   }
 429   SimpleNotify (THREAD, true) ;
 430   return OM_OK;
 431 }
< prev index next >