This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Found fix for save/load hangs in Jpcsp 64-bit
#5
Orphis is right, it should be declared volatile. The problem is actually due to optimizations done by the JIT Server Compiler such as variable caching which causes the infinite while loop, so it's not a bug but inappropriate optimization done by the JIT Server Compiler. This kind of optimization is not done in the JIT Client Compiler so that's why it works in the 32-bit Client JVM without being declared volatile.

So, the proper fix should be to change the declaration of saveListSelected on line 329 to:

protected volatile boolean saveListSelected;

and maybe clean up the while loop on line 788 as follows:

// Wait for user selection.
while (!saveListSelected && mainDisplay.isVisible()) {
// Do nothing.
}

However, it seems that there's no need to check the state of saveListSelected at all in the while loop. We need to leave the loop regardless of the state of saveListSelected since the user can just close the dialog or click the Cancel button. We only need to check whether mainDisplay is visible and exit the loop when it's no longer visible. So, the proper loop should be:

// Wait for user selection.
while (mainDisplay.isVisible()) {
// Do nothing.
}

The above works in the 32-bit Client JVM, but hangs with the JIT Server Compiler due to inappropriate optimization. Tongue Adding a sleep delay inside the while loop is still a valid workaround here, and also saves the CPU from doing unnecessary constant polling. Wink

So, I propose the following while loop:

// Wait for user selection.
while (mainDisplay.isVisible()) {
try {
Thread.sleep(250);
} catch (InterruptedException ex) {}
}

Comments and corrections are very welcome. I learn something new everyday by playing with Jpcsp. Wink
Reply


Messages In This Thread
RE: Found fix for save/load hangs in Jpcsp 64-bit - by Itaru - 01-02-2011, 07:23 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)