This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Thread suspension w/JDWP


Note that, at least as far as I know, the only acceptable ways of
waiting in a signal handler are to

a) wait on another signal with sigsuspend, or

b) sleep for short periods at a time with select()

Nothing else is async-signal-safe.  And you don't really want to
literally spin.

That aside, this sounds messy.

The GC thread-stopping code is in pthread-stop-world.c.  You probably
want to look at the GC6.6 or experimental/gc7.0alpha4 version from
http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/, since those
deal with a race condition recently discovered by the Mono developers.

My inclination would be to somehow build a single thread suspension
facility that's used by both the GC and JDWP.  Otherwise you get all
sorts of interesting issues with one trying to stop a thread that's
already stopped.  And reusing the same signal otherwise seems very
race-prone.

I think Mono does something similar, though it's been a while since we
discussed this.  You might want to look at their code.  I'd certainly
favor a solution that keeps the GC code as similar as possible.

Hans

> -----Original Message-----
> From: java-owner@gcc.gnu.org [mailto:java-owner@gcc.gnu.org] 
> On Behalf Of Keith Seitz
> Sent: Thursday, September 15, 2005 2:43 PM
> To: java@gcc.gnu.org
> Subject: Thread suspension w/JDWP
> 
> 
> Hi,
> 
> So, it's time to discuss some issues implementing the VM 
> interface for 
> GCJ. To start, I'd like to address thread suspension.
> 
> Now, I know I'm going to get people in a tizzie, but I've implemented 
> something for JDWP completely orthogonal to whatever GCJ 
> already includes.
> 
> Maybe this is okay, since Thread.suspend is not currently implemented 
> and Thread.suspend is deprecated.
> 
> Anyway, thread suspension as I've currently implemented it is 
> achieved 
> using signals and a semaphore. When it is time to suspend a 
> thread, it 
> is signalled and receiving thread then spins on the semaphore 
> until some 
> other thread increments it.
> 
> So the real question/s I have is/are: What signal to use to 
> accomplish 
> this? From the comments in posix-threads.cc, I see that the usual 
> suspects are already being used by other parts of the system.
> 
> Another interesting question (one which I cannot answer in a timely 
> fashion) involves the possibility of re-using the GC's 
> signal. If there 
> is anyone out there that is familiar with the GC, I would be 
> interested 
> in hearing from you on this topic.
> 
> Keith
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]