src/share/vm/runtime/vm_operations.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8047290final Sdiff src/share/vm/runtime

src/share/vm/runtime/vm_operations.cpp

Print this page




 374 
 375   int num_active = 0;
 376 
 377   _shutdown_thread = thr_cur;
 378   _vm_exited = true;                                // global flag
 379   for(JavaThread *thr = Threads::first(); thr != NULL; thr = thr->next())
 380     if (thr!=thr_cur && thr->thread_state() == _thread_in_native) {
 381       ++num_active;
 382       thr->set_terminated(JavaThread::_vm_exited);  // per-thread flag
 383     }
 384 
 385   return num_active;
 386 }
 387 
 388 int VM_Exit::wait_for_threads_in_native_to_block() {
 389   // VM exits at safepoint. This function must be called at the final safepoint
 390   // to wait for threads in _thread_in_native state to be quiescent.
 391   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint already");
 392 
 393   Thread * thr_cur = ThreadLocalStorage::get_thread_slow();
 394   Monitor timer(Mutex::leaf, "VM_Exit timer", true);

 395 
 396   // Compiler threads need longer wait because they can access VM data directly
 397   // while in native. If they are active and some structures being used are
 398   // deleted by the shutdown sequence, they will crash. On the other hand, user
 399   // threads must go through native=>Java/VM transitions first to access VM
 400   // data, and they will be stopped during state transition. In theory, we
 401   // don't have to wait for user threads to be quiescent, but it's always
 402   // better to terminate VM when current thread is the only active thread, so
 403   // wait for user threads too. Numbers are in 10 milliseconds.
 404   int max_wait_user_thread = 30;                  // at least 300 milliseconds
 405   int max_wait_compiler_thread = 1000;            // at least 10 seconds
 406 
 407   int max_wait = max_wait_compiler_thread;
 408 
 409   int attempts = 0;
 410   while (true) {
 411     int num_active = 0;
 412     int num_active_compiler_thread = 0;
 413 
 414     for(JavaThread *thr = Threads::first(); thr != NULL; thr = thr->next()) {




 374 
 375   int num_active = 0;
 376 
 377   _shutdown_thread = thr_cur;
 378   _vm_exited = true;                                // global flag
 379   for(JavaThread *thr = Threads::first(); thr != NULL; thr = thr->next())
 380     if (thr!=thr_cur && thr->thread_state() == _thread_in_native) {
 381       ++num_active;
 382       thr->set_terminated(JavaThread::_vm_exited);  // per-thread flag
 383     }
 384 
 385   return num_active;
 386 }
 387 
 388 int VM_Exit::wait_for_threads_in_native_to_block() {
 389   // VM exits at safepoint. This function must be called at the final safepoint
 390   // to wait for threads in _thread_in_native state to be quiescent.
 391   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint already");
 392 
 393   Thread * thr_cur = ThreadLocalStorage::get_thread_slow();
 394   Monitor timer(Mutex::leaf, "VM_Exit timer", true,
 395                 Monitor::_safepoint_check_never);
 396 
 397   // Compiler threads need longer wait because they can access VM data directly
 398   // while in native. If they are active and some structures being used are
 399   // deleted by the shutdown sequence, they will crash. On the other hand, user
 400   // threads must go through native=>Java/VM transitions first to access VM
 401   // data, and they will be stopped during state transition. In theory, we
 402   // don't have to wait for user threads to be quiescent, but it's always
 403   // better to terminate VM when current thread is the only active thread, so
 404   // wait for user threads too. Numbers are in 10 milliseconds.
 405   int max_wait_user_thread = 30;                  // at least 300 milliseconds
 406   int max_wait_compiler_thread = 1000;            // at least 10 seconds
 407 
 408   int max_wait = max_wait_compiler_thread;
 409 
 410   int attempts = 0;
 411   while (true) {
 412     int num_active = 0;
 413     int num_active_compiler_thread = 0;
 414 
 415     for(JavaThread *thr = Threads::first(); thr != NULL; thr = thr->next()) {


src/share/vm/runtime/vm_operations.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File