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

src/share/vm/runtime/vm_operations.cpp

Print this page




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

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




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