>>>>> "Calvin" == Calvin Austin <[EMAIL PROTECTED]> writes:
> Submit it as a bug and/or send us the short example, it could very well be
> another linuxthreads bug that we will have to work around or someone has
> already discovered.
Ok - I've submitted it as a bug both to the bug parade and to
blackdown's jitterbug.
For your reading pleasure, enclosed below is the current version of my
test case. It is pretty easy to cut it down to smaller examples,
especially if you are just looking for the Exception cases. All that
appears to be required is tight-loop lock contention with wait/notify
involved running on a native-threaded VM on an SMP machine (phew!).
public class Bang {
static class Variable {
private int x = -1;
private Object lock = new Object();
public void set(int y) {
synchronized (lock) {
x=y;
System.err.print("."); // do we hang completely?
lock.notifyAll();
}
}
public void print(String who) {
synchronized (lock) {
try {
lock.wait();
} catch (InterruptedException e) {}
System.err.println(who+" sees "+x);
}
}
}
Variable v = new Variable();
class Thrash implements Runnable {
int i;
public Thrash(int i) { this.i = i; }
public void run() {
for (;;) {
v.set(i);
}
}
}
class Watch implements Runnable {
String who;
public Watch(String who) { this.who = who; }
public void run() {
for (;;) {
v.print(who);
}
}
}
void start(int l) {
for (int i=0; i<l; i++) {
new Thread(new Thrash(i)).start();
}
new Thread(new Watch("first")).start();
new Thread(new Watch("second")).start();
}
public static void main(String[] arg) {
(new Bang()).start(10);
}
}
Here's another case that got me started down this whole path. Run
rmiregistry standalone. Have other processes use the registry. Get Exception:
% java -version
java version "1.2.2"
Classic VM (build Linux_JDK_1.2.2_RC4, native threads, javacomp)
% rmiregistry
java.lang.IllegalMonitorStateException: current thread not owner
at java.lang.Object.wait(Native Method)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java, Compiled Code)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:174)
pretty cool, huh?
> Java is one of the best stress tests of the linux threads library :*)
> regards
> calvin
>>
>> I've been unable to get blackdown native-thread VM implementation to
>> work properly on my x86-based SMP machine. I'd be interested in
>> corresponding with anyone who's had better luck.
>>
>> Essentially the problem is that code like:
>> synchronized (lock) {
>> lock.wait();
>> }
>> results in exceptions like:
>> java.lang.IllegalMonitorStateException: current thread not owner
>> at java.lang.Object.wait(Native Method)
>> at java.lang.Object.wait(Object.java, Compiled Code)
>> ...
>>
>> I see it happening in my code, in jdk code (e.g. rmiregistry) and in
>> third-party code. I have a short example which makes the bogon
>> trivially reproducable.
>>
>> I haven't had any problems on single-cpu machines, though I run a
>> different kernel on those machines.
>>
>> I'm mostly using Blackdown 1.2.2RC4 with javacomp (though jit doesn't
>> seem to matter). IBM JDK1.3 beta exhibits almost identical behavior.
>> The "Sun" 1.3 beta with hotspot actually doesn't throw these
>> exceptions - it silently hangs instead.
>>
>> BTW - I'm using a 2-cpu intel machine w/ various late-2.3-series
>> kernels and glibc 2.1.3.
>>
>> Should I just give up on SMP+Java for the foreseeable future or what?
>>
>> thanks,
>> -mik
>> --
>> Michael Thome ([EMAIL PROTECTED])
>>
>>
>> ----------------------------------------------------------------------
>> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
>> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
>>
--
Michael Thome ([EMAIL PROTECTED])
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]