[Top][All Lists]

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

Proposal for changes to Classpath's JNI libraries

From: Stephen Crawley
Subject: Proposal for changes to Classpath's JNI libraries
Date: Mon, 02 Dec 2002 23:01:32 +1000


Summary:  This email proposes some changes to Classpath to accomodate 
Kissme.  Could people with an interest in the Classpath native libraries
(specifically the JNI ones) please read this proposal, and post your


Those of you have been following the Kissme mailing list will know
that we've had a long-standing problem with Kissme garbage collection
and IO.  In a nutshell, the Kissme garbage collector can only run
when all threads are within a "GC point".  Normal Java code regularly
enters (and exits) GC points, and native code will get there eventually.

However, a thread will not enter a GC point while it is performing
a (potentially) blocking IO syscall; e.g. a read, write, open, close, 
listen, accept or connect.  If the GC needs to run while the syscall
is in progress, the Kissme VM locks up.  While we originally thought
this was just a theoretical problem, it turns out that it is pretty
much inevitable in any program that implements a network server.

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.

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:

  1)  Add a ./configure switch to enable some Kissme-specific JNI extensions.

  2)  Add #ifdefs to classpath/include/jni.h to enable Kissme-specific
      JNI functions at the end of the function table.  These include 
      functions for entering and exiting Kissme GC points.

  3)  Some other tweaking is required so that classpath/include/jni.h can
      be #included by Kissme VM code.  (We need to disable the declaration
      of certain JVM implementation-specific types as "void *" ...)

  4)  Add calls to the GC point enter/exit functions around all blocking
      I/O syscalls in the Classpath native code libraries.  These calls
      are within Kissme #ifdefs.

Patches to Classpath and Kissme to implement the above are provided as
attachments.  These are relative the CVS repositories as of about 1/2
hour ago.  I've also added a new "hitme" test to the Kissme CVS
repository that show that blocked read and write Java method calls don't
block garbage collection.

If you currently use Kissme & Classpath and have time, could you please
try out the patches and let me know if they work for you.  Also, let me
know if you think that Kissme-specific stuff in the Classpath source
code base is (un-)acceptable.

-- Steve

[*  Actually, the patches also fix a bug in classpath/include/jni.h.  
    A couple of JNI functions have been transposed ... according to
    the Sun JNI 1.2 spec.]

Attachment: kissme.diffs
Description: kissme.diffs

Attachment: classpath.diffs
Description: classpath.diffs

reply via email to

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