[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Java JNI && MzScheme?
This is a reply for a message that I lost track of long ago (so long
ago that Giorgio might no longer care about an answer).
Quoting Giorgio Scorzelli:
> I'm trying to create a Windows DLL that implements a NATIVE method of
> a Java class (see JNI documentation) and which should embed inside the
> well-known MzScheme interpreter.
The main problem is that the JVM will likely execute multiple threads,
and the threads will likely confuse MzScheme (or, more specifically,
its GC).
> I execute in my DLL the following action :
>
> JNIEXPORT jstring JNICALL Java_PlasmServer_Eval(JNIEnv *env, jclass obj, jstring cmd)
> {
> Scheme_Env* env=scheme_basic_env();//PROBLEM HERE!!!
> [...]
> }
It might be enough to set the variable GC_use_registered_statics to 1
before calling scheme_basic_env(). That "magically" avoids certain
thread problems in Windows.
Others have reported problems in embedding MzScheme into a
multithreaded app, and I don't think we've discovered all the problems
and solutions. For some platforms, the stack base is a problem; in
version 199.x, GC_use_registered_statics has been replaced/extended by
a scheme_set_stack_base() function that takes two arguments: a stack
base or NULL (= auto-find stack), and a flag indicating whether to
auto-find static variables.
Matthew