Compiling kaffe classes

Godmar Back gback at
Mon Apr 12 08:48:14 PDT 1999

> Santoro Corrado wrote:
> | Ok, please let me know when the patch is ready, because I've not found any
> | java package for alpha/linux. The only porting of JDK that I've found in
> | Internet does not use native threads, so each time a blocking call is
> | issued, every thread is suspended :((((
> Nor are you likely to.
> Garbage collection imposes two extra constraints on a threading system:
> 1. When a GC is started, all other threads must be stopped so that they don't
>    change the reachability state of the heap while the GC is running.  This
>    does not apply if an incremental GC algorithm is used.  In any case,
>    allowing one thread to stop all others is not a primitive operation in
>    most native thread systems.
> 2. The GC requires access to the saved register files of all other threads,
>    because it is possible that the only reachable pointer to an object is in
>    a register.  Again, such access is not a primitive operation in most thread
>    systems.
> Providing these operations may not be possible.  e.g. some thread systems may
> decide to perform the thread switching in the kernel.  If they don't provide
> a system call for #2, then it is simply not possible to get at the registers.
> Providing function #1 on a multiprocessor system can be quite expensive.
> Rather, Kaffe and other JVMs roll their own thread systems, where this
> functionality can be provided.

You're right that thread stopping can be expensive on native threading
systems, but it's not impossible.

One approach is to use an unused signal and pthread_kill the other
threads.  Then, have them block and report back in their
signal handler.  Since the signal handler gives you the context including
all registers, your pretty much set....

In our case, since our gc is not yet fully precise, we need even less
information, we only need to estimate the sp.  Such an estimate is easily
obtained by taking the address of a local.

In theory.  In practice, this implementation is hard to get right, for
various reasons.  It works neither in Blackdown's JDK1.1.7-native nor in 
Kaffe's linux-threads reliably.  I don't know how reliably it works for the
people using Boehm's gc (they use the same trick).

But the code is there, and it needs to be debugged.
Configure with --with-threads=linux-threads to get it.
Linux even provides reasonable gdb support.

	- Godmar

More information about the kaffe mailing list