Kaffe and Native Threads
tony at magg.net
Mon Dec 1 16:25:45 PST 1997
> I am interested in finding out which operating systems Kaffe has
> currently been ported to using native threads. If anyone has done a
> Kaffe port using native threads (especially for real-time operating
> systems), please let me know.
I have no advice but I think this is a good place to start discussion
about native threads. I am spending some time trying to see how
to implement Java threads in Kaffe via Win32 native threads.
The major problem here are Win32 native threads themselves
and the fact that it is very difficult to control one thread from
another. In particular, there is no good way to stop one thread
( target thread) from other thread ( caller thread).
It is possible to use Win32 Events. In this scenario caller thread
can pulse event when it wishes target to stop. Target thread would wait on
event and would cleanly exit when event is in signalled state. The problems
here are in arranging for target thread, which is executing Java methods,
to also wait for an event and the resulting timing issues.
It is necessary to arrange somehow that target thread does
not wait too much, just checking if another thread wants it to stop.
It should primarily execute the code in run() Java method. The problem
is also deciding where, in this execution, to put event waits.
Another approach is to use Win32 signals() but these seem to be
implemented as exceptions and appartently work only in the
context of the single thread - i.e. you can not signal another thread.
Cygnus Cygwin.dll provides emulation of Unix signals on Win32
but this seems to have problems too, and on Windows 95 in
particular. According to some articles in mailing list Cygwin signals
are implemented by blocking the current thread, calling the
signal function and then resuming blocked thread. There are particular
cases when Windows 95 is in such a state that this behavior will
crash the system.
More information about the kaffe