[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Proposal for changes to Classpath's JNI libraries

From: Etienne M. Gagnon
Subject: Re: Proposal for changes to Classpath's JNI libraries
Date: Mon, 2 Dec 2002 09:11:54 -0500
User-agent: Mutt/1.4i

On Mon, Dec 02, 2002 at 11:01:32PM +1000, Stephen Crawley wrote:
> In theory, the fix is simple; perform all blocking syscalls from within
> GC points.  In practice, Kissme uses the Classpath native libraries for
> Java I/O.  Therefore, we must:
>   EITHER implement our own native I/O libraries,
>   OR make some Kissme-specific changes to the Classpath sourcecode base.

This is not true.  You simply need considers all JNI calls as GC
points.  In other words, as soon as a thread enters native code, it is
considered GC safe, as no reference can be directly touched by that
thread (all references being hidden within native global/local
reference black structures).  The important thing is to block such
native thread if it ever calls back the JVM (through the JNIEnv
function pointers) while GC is running.

> I've explored the latter approach and found that it can be done in a
> way that should be invisible[*] to other VMs that use the Classpath native
> libraries.  Here is how this works:

Even though these changes would be invisible to other VMs, I think it
would be bad design for Kissme.  Have you considered what would happen
if a "user supplied" JNI library contained a blocking call, or some
kind of infinite loop without call-backs into the Kissme JVM?  Such a
library would deadlock the Kissme JVM if GC was required on another
thread.  Unless, of course, you had the intention to require users to
make Kissme-specific calls around such things, which defeats the
purpose of a "Standard native interface" (JNI).

SableVM uses a single atomic operation (Compare-And-Swap) around JNI
calls to manage thread GC state without causing the overhead of a full
mutex lock call.  I could explain to you the algorithm.  I am
currently putting the *final* post-defense/evaluation touch to my
Ph.D. thesis document (I have just successfully defended it last
week).  If I have time, I might add an appendix that describes the
implemented stop-the-world algorithm.


Etienne M. Gagnon          

reply via email to

[Prev in Thread] Current Thread [Next in Thread]