Kaffe and Native Threads
John D. Gwinner
gwinner at northnet.org
Mon Dec 1 19:30:58 PST 1997
> 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).
Hmm ... do you have the book "Multithreading applications in Win32"? It's
pretty good for a much better understanding of these issues. In any
event, what about a mutex or a semaphore?
> It is possible to use Win32 Events. In this scenario caller thread
> can pulse event when it wishes target to stop.
Dangerous, as if the target isn't waiting, the pulse can loose an event
(depending on if you've got an auto-reset event).
> The problems
> here are in arranging for target thread, which is executing Java
> to also wait for an event and the resulting timing issues.
This does sound like a problem... you really don't want much of a wait,
you really just want to check if you need to suspend at the end of a loop.
Hmm ... maybe a mutex or a semaphore for 'Run' ... when the thread
controller decides that it's time for another thread to run, it grabs the
semaphore, and then other threads will block (as they can't get it)
allowing the thread controller to unblock the proper thread?
I haven't looked closely at the Kaffe threading since a while ago, when I
had the most trouble with getting that to compile. Since then, it looks
like Java has loosened it's licensing restrictions (re: the huge
discussion we had a while ago) so I haven't investigate this yet. I'd
still love to use Kaffe and Guava instead though!
> Cygnus Cygwin.dll provides emulation of Unix signals on Win32
> but this seems to have problems too, and on Windows 95 in
I really wouldn't recommend this as a gut feeling; Win32 has better
methods in some cases, depending on what's trying to be accomplished. I'm
not trying to ding signals; I'm just saying that when Win32 can't do
something, or doesn't handle it well, that's usually because there's
something different to take it's place. For example, Semaphores are
rarely used, as Mutex's are somewhat more useful. However, Mutex's are
slower than Events.
BTW, we'll see what happens with this message and bad addressee's/returned
mail; I think it's a 'reply to' or 'errors-to' that's configured wrong.
== John ==
More information about the kaffe