Path: blob/master/src/java.management/share/native/libmanagement/ThreadImpl.c
41149 views
/*1* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include <jni.h>26#include "jvm.h"27#include "management.h"28#include "sun_management_ThreadImpl.h"2930JNIEXPORT void JNICALL31Java_sun_management_ThreadImpl_setThreadContentionMonitoringEnabled032(JNIEnv *env, jclass cls, jboolean flag)33{34jmm_interface->SetBoolAttribute(env, JMM_THREAD_CONTENTION_MONITORING, flag);35}3637JNIEXPORT void JNICALL38Java_sun_management_ThreadImpl_setThreadCpuTimeEnabled039(JNIEnv *env, jclass cls, jboolean flag)40{41jmm_interface->SetBoolAttribute(env, JMM_THREAD_CPU_TIME, flag);42}4344JNIEXPORT void JNICALL45Java_sun_management_ThreadImpl_setThreadAllocatedMemoryEnabled046(JNIEnv *env, jclass cls, jboolean flag)47{48jmm_interface->SetBoolAttribute(env, JMM_THREAD_ALLOCATED_MEMORY, flag);49}5051JNIEXPORT void JNICALL52Java_sun_management_ThreadImpl_getThreadInfo153(JNIEnv *env, jclass cls, jlongArray ids, jint maxDepth,54jobjectArray infoArray)55{56jmm_interface->GetThreadInfo(env, ids, maxDepth, infoArray);57}5859JNIEXPORT jobjectArray JNICALL60Java_sun_management_ThreadImpl_getThreads61(JNIEnv *env, jclass cls)62{63return JVM_GetAllThreads(env, cls);64}6566JNIEXPORT jlong JNICALL67Java_sun_management_ThreadImpl_getThreadTotalCpuTime068(JNIEnv *env, jclass cls, jlong tid)69{70return jmm_interface->GetThreadCpuTimeWithKind(env, tid, JNI_TRUE /* user+sys */);71}7273JNIEXPORT void JNICALL74Java_sun_management_ThreadImpl_getThreadTotalCpuTime175(JNIEnv *env, jclass cls, jlongArray ids, jlongArray timeArray)76{77jmm_interface->GetThreadCpuTimesWithKind(env, ids, timeArray,78JNI_TRUE /* user+sys */);79}8081JNIEXPORT jlong JNICALL82Java_sun_management_ThreadImpl_getThreadUserCpuTime083(JNIEnv *env, jclass cls, jlong tid)84{85return jmm_interface->GetThreadCpuTimeWithKind(env, tid, JNI_FALSE /* user */);86}8788JNIEXPORT void JNICALL89Java_sun_management_ThreadImpl_getThreadUserCpuTime190(JNIEnv *env, jclass cls, jlongArray ids, jlongArray timeArray)91{92jmm_interface->GetThreadCpuTimesWithKind(env, ids, timeArray,93JNI_FALSE /* user */);94}9596JNIEXPORT jlong JNICALL97Java_sun_management_ThreadImpl_getThreadAllocatedMemory098(JNIEnv *env, jclass cls, jlong tid)99{100return jmm_interface->GetOneThreadAllocatedMemory(env, tid);101}102103JNIEXPORT void JNICALL104Java_sun_management_ThreadImpl_getThreadAllocatedMemory1105(JNIEnv *env, jclass cls, jlongArray ids, jlongArray sizeArray)106{107jmm_interface->GetThreadAllocatedMemory(env, ids, sizeArray);108}109110JNIEXPORT jobjectArray JNICALL111Java_sun_management_ThreadImpl_findMonitorDeadlockedThreads0112(JNIEnv *env, jclass cls)113{114return jmm_interface->FindCircularBlockedThreads(env);115}116117JNIEXPORT jobjectArray JNICALL118Java_sun_management_ThreadImpl_findDeadlockedThreads0119(JNIEnv *env, jclass cls)120{121return jmm_interface->FindDeadlocks(env, JNI_FALSE /* !object_monitors_only */);122}123124JNIEXPORT void JNICALL125Java_sun_management_ThreadImpl_resetPeakThreadCount0126(JNIEnv *env, jclass cls)127{128jvalue unused;129unused.i = 0;130jmm_interface->ResetStatistic(env, unused, JMM_STAT_PEAK_THREAD_COUNT);131}132133JNIEXPORT void JNICALL134Java_sun_management_ThreadImpl_resetContentionTimes0135(JNIEnv *env, jobject dummy, jlong tid)136{137jvalue value;138value.j = tid;139jmm_interface->ResetStatistic(env, value, JMM_STAT_THREAD_CONTENTION_TIME);140}141142JNIEXPORT jobjectArray JNICALL143Java_sun_management_ThreadImpl_dumpThreads0144(JNIEnv *env, jclass cls, jlongArray ids, jboolean lockedMonitors,145jboolean lockedSynchronizers, jint maxDepth)146{147return jmm_interface->DumpThreads(env, ids, lockedMonitors,148lockedSynchronizers, maxDepth);149}150151152