blob: 19bfb7bb3e5e6186e90502f98c97ad165735a50d [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26#include <jni.h>
27#include "jvm.h"
28#include "management.h"
29#include "sun_management_ThreadImpl.h"
30
31JNIEXPORT void JNICALL
32Java_sun_management_ThreadImpl_setThreadContentionMonitoringEnabled0
33 (JNIEnv *env, jclass cls, jboolean flag)
34{
35 jmm_interface->SetBoolAttribute(env, JMM_THREAD_CONTENTION_MONITORING, flag);
36}
37
38JNIEXPORT void JNICALL
39Java_sun_management_ThreadImpl_setThreadCpuTimeEnabled0
40 (JNIEnv *env, jclass cls, jboolean flag)
41{
42 jmm_interface->SetBoolAttribute(env, JMM_THREAD_CPU_TIME, flag);
43}
44
45
46JNIEXPORT void JNICALL
47Java_sun_management_ThreadImpl_getThreadInfo0
48 (JNIEnv *env, jclass cls, jlongArray ids, jint maxDepth,
49 jobjectArray infoArray)
50{
51 jmm_interface->GetThreadInfo(env, ids, maxDepth, infoArray);
52}
53
54JNIEXPORT jobjectArray JNICALL
55Java_sun_management_ThreadImpl_getThreads
56 (JNIEnv *env, jclass cls)
57{
58 return JVM_GetAllThreads(env, cls);
59}
60
61JNIEXPORT jlong JNICALL
62Java_sun_management_ThreadImpl_getThreadTotalCpuTime0
63 (JNIEnv *env, jclass cls, jlong tid)
64{
65 return jmm_interface->GetThreadCpuTimeWithKind(env, tid, JNI_TRUE /* user+sys */);
66}
67
68JNIEXPORT jlong JNICALL
69Java_sun_management_ThreadImpl_getThreadUserCpuTime0
70 (JNIEnv *env, jclass cls, jlong tid)
71{
72 return jmm_interface->GetThreadCpuTimeWithKind(env, tid, JNI_FALSE /* user */);
73}
74
75JNIEXPORT jobjectArray JNICALL
76Java_sun_management_ThreadImpl_findMonitorDeadlockedThreads0
77 (JNIEnv *env, jclass cls)
78{
79 return jmm_interface->FindCircularBlockedThreads(env);
80}
81
82JNIEXPORT jobjectArray JNICALL
83Java_sun_management_ThreadImpl_findDeadlockedThreads0
84 (JNIEnv *env, jclass cls)
85{
86 return jmm_interface->FindDeadlocks(env, JNI_FALSE /* !object_monitors_only */);
87}
88
89JNIEXPORT void JNICALL
90Java_sun_management_ThreadImpl_resetPeakThreadCount0
91 (JNIEnv *env, jclass cls)
92{
93 jvalue unused;
94 unused.i = 0;
95 jmm_interface->ResetStatistic(env, unused, JMM_STAT_PEAK_THREAD_COUNT);
96}
97
98JNIEXPORT void JNICALL
99Java_sun_management_ThreadImpl_resetContentionTimes0
100 (JNIEnv *env, jobject dummy, jlong tid)
101{
102 jvalue value;
103 value.j = tid;
104 jmm_interface->ResetStatistic(env, value, JMM_STAT_THREAD_CONTENTION_TIME);
105}
106
107JNIEXPORT jobjectArray JNICALL
108Java_sun_management_ThreadImpl_dumpThreads0
109 (JNIEnv *env, jclass cls, jlongArray ids, jboolean lockedMonitors, jboolean lockedSynchronizers)
110{
111 return jmm_interface->DumpThreads(env, ids, lockedMonitors, lockedSynchronizers);
112}