Problems compiling on NetBSD/m68k

Godmar Back gback at cs.utah.edu
Sun Feb 21 15:37:51 PST 1999


> 
> A question somewhat related to this:
> What happens with JNI? I mean if I use IO in a C function linked using JNI,
> will it use the Syscall interface?
> 

JNI doesn't specify this.  In fact, Sun doesn't even acknowledge that there
is a problem.  On the other hand, I don't blame them: it's not a problem
if you use native threads, and defining the behavior may amount to a
document the size of posix specification.

There are at least two problems.  The first problem affect the unix-jthreads
version of Kaffe and is the well-known problem of user-level threading
packages that all I/O must go through them to avoid blocking the whole
process because a single thread attempts to do I/O.

In Kaffe, you need to use the syscall interface when doing IO from all
native code, unless you're using one of the native thread ports of Kaffe
(only the oskit-pthreads port is completely functional at this point.)
If it's unavoidable, you can of course call these functions directly,
with the described consequences.

The second problem you already eluded to is the issue of calling 
thread-unsafe functions from native code, such as malloc. 

For these cases, you need to wrap your call into

	enterUnsafeRegion();
	...
	leaveUnsafeRegion();

This will turn context switches off.  Note that you cannot signal errors
via SignalError while executing in an unsafe region.

It's kind of a mess, but the best we can do without resorting to
providing our own libc or using platform-specific linker tricks.

	- Godmar



More information about the kaffe mailing list