comparison src/share/vm/runtime/serviceThread.cpp @ 10215:31a4e55f8c9d

8004095: Add support for JMX interface to Diagnostic Framework and Commands Reviewed-by: acorn, sla
author fparain
date Fri, 03 May 2013 05:05:31 -0700
parents 78542e2b5e35
children ad3f8397fe37 fa6c442c59ee
comparison
equal deleted inserted replaced
10167:8fe2542bdc8d 10215:31a4e55f8c9d
1 /* 1 /*
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
27 #include "runtime/javaCalls.hpp" 27 #include "runtime/javaCalls.hpp"
28 #include "runtime/serviceThread.hpp" 28 #include "runtime/serviceThread.hpp"
29 #include "runtime/mutexLocker.hpp" 29 #include "runtime/mutexLocker.hpp"
30 #include "prims/jvmtiImpl.hpp" 30 #include "prims/jvmtiImpl.hpp"
31 #include "services/gcNotifier.hpp" 31 #include "services/gcNotifier.hpp"
32 #include "services/diagnosticArgument.hpp"
33 #include "services/diagnosticFramework.hpp"
32 34
33 ServiceThread* ServiceThread::_instance = NULL; 35 ServiceThread* ServiceThread::_instance = NULL;
34 36
35 void ServiceThread::initialize() { 37 void ServiceThread::initialize() {
36 EXCEPTION_MARK; 38 EXCEPTION_MARK;
81 void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) { 83 void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) {
82 while (true) { 84 while (true) {
83 bool sensors_changed = false; 85 bool sensors_changed = false;
84 bool has_jvmti_events = false; 86 bool has_jvmti_events = false;
85 bool has_gc_notification_event = false; 87 bool has_gc_notification_event = false;
88 bool has_dcmd_notification_event = false;
86 JvmtiDeferredEvent jvmti_event; 89 JvmtiDeferredEvent jvmti_event;
87 { 90 {
88 // Need state transition ThreadBlockInVM so that this thread 91 // Need state transition ThreadBlockInVM so that this thread
89 // will be handled by safepoint correctly when this thread is 92 // will be handled by safepoint correctly when this thread is
90 // notified at a safepoint. 93 // notified at a safepoint.
96 ThreadBlockInVM tbivm(jt); 99 ThreadBlockInVM tbivm(jt);
97 100
98 MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag); 101 MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
99 while (!(sensors_changed = LowMemoryDetector::has_pending_requests()) && 102 while (!(sensors_changed = LowMemoryDetector::has_pending_requests()) &&
100 !(has_jvmti_events = JvmtiDeferredEventQueue::has_events()) && 103 !(has_jvmti_events = JvmtiDeferredEventQueue::has_events()) &&
101 !(has_gc_notification_event = GCNotifier::has_event())) { 104 !(has_gc_notification_event = GCNotifier::has_event()) &&
105 !(has_dcmd_notification_event = DCmdFactory::has_pending_jmx_notification())) {
102 // wait until one of the sensors has pending requests, or there is a 106 // wait until one of the sensors has pending requests, or there is a
103 // pending JVMTI event or JMX GC notification to post 107 // pending JVMTI event or JMX GC notification to post
104 Service_lock->wait(Mutex::_no_safepoint_check_flag); 108 Service_lock->wait(Mutex::_no_safepoint_check_flag);
105 } 109 }
106 110
118 } 122 }
119 123
120 if(has_gc_notification_event) { 124 if(has_gc_notification_event) {
121 GCNotifier::sendNotification(CHECK); 125 GCNotifier::sendNotification(CHECK);
122 } 126 }
127
128 if(has_dcmd_notification_event) {
129 DCmdFactory::send_notification(CHECK);
130 }
123 } 131 }
124 } 132 }
125 133
126 bool ServiceThread::is_service_thread(Thread* thread) { 134 bool ServiceThread::is_service_thread(Thread* thread) {
127 return thread == _instance; 135 return thread == _instance;