void ChameleonMScreen::slotTimeout() { jlong ms; if (vm_stopped) { return; } /* check and align stack suspend/resume state */ midp_checkAndResume(); ms = vm_suspended ? SR_RESUME_CHECK_TIMEOUT : JVM_TimeSlice(); /* Let the VM run for some time */ if (ms <= -2) { /* * JVM_Stop was called. Avoid call JVM_TimeSlice again until * startVM is called. */ vm_stopped = true; qteapp_get_application()->exit_loop(); } else if (ms == -1) { /* * Wait forever -- we probably have a thread blocked on IO or GUI. * No need to set up timer from here */ } else { if (ms > 0x7fffffff) { vm_slicer.start(0x7fffffff, TRUE); } else { vm_slicer.start((int)(ms & 0x7fffffff), TRUE); } } }
int main(int argc, char **argv) { #if ENABLE_PCSL pcsl_mem_initialize(NULL, 0); #endif // Call this before any other Jvm_ functions. JVM_Initialize(); // Ignore arg[0] -- the name of the program. argc --; argv ++; while (true) { int n = JVM_ParseOneArg(argc, argv); if (n < 0) { JVMSPI_DisplayUsage(NULL); return -1; } else if (n == 0) { break; } argc -= n; argv += n; } int rv; if (JVM_GetConfig(JVM_CONFIG_SLAVE_MODE) == KNI_FALSE) { // Run the VM in regular mode -- JVM_Start won't return until // the VM completes execution. rv = JVM_Start(NULL, NULL, argc, argv); } else { JVM_Start(NULL, NULL, argc, argv); for (;;) { jlong timeout = JVM_TimeSlice(); if (timeout <= ((jlong)-2)) { break; } else { int blocked_threads_count; JVMSPI_BlockedThreadInfo * blocked_threads; blocked_threads = SNI_GetBlockedThreads(&blocked_threads_count); JVMSPI_CheckEvents(blocked_threads, blocked_threads_count, timeout); } } rv = JVM_CleanUp(); } printf("ADSEXITCODE=%d\n", rv); #if ENABLE_PCSL pcsl_mem_finalize(); #endif return rv; }
int main(int argc, char **argv) { int code = 0; #if ENABLE_PCSL pcsl_mem_initialize(NULL, 0); #endif // Call this before any other Jvm_ functions. JVM_Initialize(); // Ignore arg[0] -- the name of the program. argc --; argv ++; while (true) { int n = JVM_ParseOneArg(argc, argv); if (n < 0) { printf("Unknown argument: %s\n", argv[0]); JVMSPI_DisplayUsage(NULL); code = -1; goto end; } else if (n == 0) { break; } argc -= n; argv += n; } if (JVM_GetConfig(JVM_CONFIG_SLAVE_MODE) == KNI_FALSE) { // Run the VM in regular mode -- JVM_Start won't return until // the VM completes execution. code = JVM_Start(NULL, NULL, argc, argv); } else { // Run the VM in slave mode -- we keep calling JVM_TimeSlice(), // which executes bytecodes for a small amount and returns. This // mode is necessary for platforms that need to keep the main // control loop outside of of the VM. // // Note that this mode is not necessary on Win32. We do it here // just as a demo. JVM_Start(NULL, NULL, argc, argv); for (;;) { jlong timeout = JVM_TimeSlice(); if (timeout <= -2) { break; } else { int blocked_threads_count; JVMSPI_BlockedThreadInfo * blocked_threads; blocked_threads = SNI_GetBlockedThreads(&blocked_threads_count); JVMSPI_CheckEvents(blocked_threads, blocked_threads_count, timeout); } } code = JVM_CleanUp(); } end: #if ENABLE_PCSL pcsl_mem_finalize(); #endif return code; }