Assigning the JVM a given processor.
843829Jul 27 2004 — edited Jul 27 2004All,
I have a C++ executable which assigns starts a JVM through a JNI call.
I am attempting to find a way to assign the JVM and it's associated threads
to the second processor on my Win2K system.
At this time the first processor is doing a lot of work while the second is hardly busy.
I want to speed up the time it takes to lauch the Java GUI through the JNI call and
perhaps give other C++ processes more time on the first processor.
1) Is there a way to assign the JVM processor through Java itself? (I have not been able to find out)
2) Does the JVM become a "thread group" on a Win2K machine?
3) Is there a way to assign a given JVM thread to a processor?
Any help would be appreciated.
The follow code fragment is what I have tried:
*************
JavaVMOption options[2];
JavaVMInitArgs vm_args;
jmethodID main_id;
long result;
jfieldID fid;
jclass cls;
jobject jobj;
int i,asize;
jobjectArray args;
jstring js;
options[0].optionString = "-Djava.class.path=.;.\\xerces.jar"; // & M DW00000453
options[1].optionString = "-Djava.compiler=NONE";
vm_args.version=JNI_VERSION_1_4; // & A TC007
vm_args.options=options;
vm_args.nOptions=2;
vm_args.ignoreUnrecognized=JNI_FALSE;
result=JNI_CreateJavaVM(&jvm,(void**)&jenvHandle,&vm_args);
//SetThreadIdealProcessor(jvm, 0x00000002);
//SetProcessAffinityMask(jvm.getProcessId(),0x00000001);
/// ******* Try to place the JVM on the 2nd processor. ***************
SetProcessAffinityMask(jenvHandle,0x00000002);
cls = jenvHandle->FindClass("JavaJNIInt");
main_id=jenvHandle->GetStaticMethodID(cls,"main","([Ljava/lang/String;)V");