< prev index next >

src/hotspot/share/runtime/serviceThread.cpp

Print this page
rev 51795 : imported patch fix


  69                                     os::native_thread_creation_failed_msg());
  70     }
  71 
  72     java_lang_Thread::set_thread(thread_oop(), thread);
  73     java_lang_Thread::set_priority(thread_oop(), NearMaxPriority);
  74     java_lang_Thread::set_daemon(thread_oop());
  75     thread->set_threadObj(thread_oop());
  76     _instance = thread;
  77 
  78     Threads::add(thread);
  79     Thread::start(thread);
  80   }
  81 }
  82 
  83 void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) {
  84   while (true) {
  85     bool sensors_changed = false;
  86     bool has_jvmti_events = false;
  87     bool has_gc_notification_event = false;
  88     bool has_dcmd_notification_event = false;
  89     bool acs_notify = false;
  90     bool stringtable_work = false;
  91     bool symboltable_work = false;
  92     bool resolved_method_table_work = false;
  93     bool protection_domain_table_work = false;
  94     JvmtiDeferredEvent jvmti_event;
  95     {
  96       // Need state transition ThreadBlockInVM so that this thread
  97       // will be handled by safepoint correctly when this thread is
  98       // notified at a safepoint.
  99 
 100       // This ThreadBlockInVM object is not also considered to be
 101       // suspend-equivalent because ServiceThread is not visible to
 102       // external suspension.
 103 
 104       ThreadBlockInVM tbivm(jt);
 105 
 106       MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
 107       while (!(sensors_changed = LowMemoryDetector::has_pending_requests()) &&
 108              !(has_jvmti_events = JvmtiDeferredEventQueue::has_events()) &&
 109               !(has_gc_notification_event = GCNotifier::has_event()) &&
 110               !(has_dcmd_notification_event = DCmdFactory::has_pending_jmx_notification()) &&
 111               !(stringtable_work = StringTable::has_work()) &&
 112               !(symboltable_work = SymbolTable::has_work()) &&
 113               !(resolved_method_table_work = ResolvedMethodTable::has_work()) &&
 114               !(protection_domain_table_work = SystemDictionary::pd_cache_table()->has_work())) {
 115         // wait until one of the sensors has pending requests, or there is a
 116         // pending JVMTI event or JMX GC notification to post

 117         Service_lock->wait(Mutex::_no_safepoint_check_flag);
 118       }
 119 
 120       if (has_jvmti_events) {
 121         jvmti_event = JvmtiDeferredEventQueue::dequeue();
 122       }
 123     }
 124 
 125     if (stringtable_work) {
 126       StringTable::do_concurrent_work(jt);
 127     }
 128 
 129     if (symboltable_work) {
 130       SymbolTable::do_concurrent_work(jt);
 131     }
 132 
 133     if (has_jvmti_events) {
 134       jvmti_event.post();
 135     }
 136 




  69                                     os::native_thread_creation_failed_msg());
  70     }
  71 
  72     java_lang_Thread::set_thread(thread_oop(), thread);
  73     java_lang_Thread::set_priority(thread_oop(), NearMaxPriority);
  74     java_lang_Thread::set_daemon(thread_oop());
  75     thread->set_threadObj(thread_oop());
  76     _instance = thread;
  77 
  78     Threads::add(thread);
  79     Thread::start(thread);
  80   }
  81 }
  82 
  83 void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) {
  84   while (true) {
  85     bool sensors_changed = false;
  86     bool has_jvmti_events = false;
  87     bool has_gc_notification_event = false;
  88     bool has_dcmd_notification_event = false;

  89     bool stringtable_work = false;
  90     bool symboltable_work = false;
  91     bool resolved_method_table_work = false;
  92     bool protection_domain_table_work = false;
  93     JvmtiDeferredEvent jvmti_event;
  94     {
  95       // Need state transition ThreadBlockInVM so that this thread
  96       // will be handled by safepoint correctly when this thread is
  97       // notified at a safepoint.
  98 
  99       // This ThreadBlockInVM object is not also considered to be
 100       // suspend-equivalent because ServiceThread is not visible to
 101       // external suspension.
 102 
 103       ThreadBlockInVM tbivm(jt);
 104 
 105       MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
 106       // Use arithmetic-or to combine results; we don't want short-circuiting.
 107       while (((sensors_changed = LowMemoryDetector::has_pending_requests()) |
 108               (has_jvmti_events = JvmtiDeferredEventQueue::has_events()) |
 109               (has_gc_notification_event = GCNotifier::has_event()) |
 110               (has_dcmd_notification_event = DCmdFactory::has_pending_jmx_notification()) |
 111               (stringtable_work = StringTable::has_work()) |
 112               (symboltable_work = SymbolTable::has_work()) |
 113               (resolved_method_table_work = ResolvedMethodTable::has_work()) |
 114               (protection_domain_table_work = SystemDictionary::pd_cache_table()->has_work()))
 115              == 0) {
 116         // Wait until notified that there is some work to do.
 117         Service_lock->wait(Mutex::_no_safepoint_check_flag);
 118       }
 119 
 120       if (has_jvmti_events) {
 121         jvmti_event = JvmtiDeferredEventQueue::dequeue();
 122       }
 123     }
 124 
 125     if (stringtable_work) {
 126       StringTable::do_concurrent_work(jt);
 127     }
 128 
 129     if (symboltable_work) {
 130       SymbolTable::do_concurrent_work(jt);
 131     }
 132 
 133     if (has_jvmti_events) {
 134       jvmti_event.post();
 135     }
 136 


< prev index next >