[cp-patches] RFC: JDWP startup synchronization (revisited)
keiths at redhat.com
Thu Jun 15 22:02:32 UTC 2006
I would like to revisit this topic again. I don't know if anyone
attempting to implement JDWP is having startup problems, but I certainly
am with gij. Basically, we need to know exactly when the entire JDWP
backend is ready to go, otherwise we end up trying to send event
notifications before the debugger is attached and all kinds of other mess.
So I've come up with a rather hacky approach to do this synchronization.
The idea is simple: gnu.classpath.jdwp.Jdwp, which already does
initialization in its own thread, now contains basically a condition
variable. When the condition variable hits a certain count (indicating
that all subcomponents are initialized), the thread sets the global
"isDebugging" flag, and exits. Thus the caller can simply join or
WaitForSingleObject on that thread. When it exits, everything is ready.
While this *is* hacky (a thread exit doesn't really sound like a very
explicit/obvious way of implementing this), but it is extremely simple.
I tried using "standard" Object.wait-like stuff for this, but it seems
to me that while this would be trivial to implement with gcj, it might
be quite sloppy in other VMs which have to use JNI. [Besides I haven't
gotten that to work properly with gij -- it seems I can't get
something(s) set up sufficiently to allow Object.wait to be called.]
I've attached the patches for this scheme. What do people think? [I'll
include a changelog entry for the heck of it, I guess.]
I would appreciate comments (for or against).
2006-06-15 Keith Seitz <keiths at redhat.com>
* gnu/classpath/jdwp/Jdwp.java (_initLock): New field.
(_initCount): New field.
(Jdwp): Don't set isDebugging until fully initialized.
(subcomponentInitialized): New method.
(run): Wait for PacketProcessor and JdwpConnection to
startup, then set isDebugging, and then let this thread
(run): Add synchronization notification.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4429 bytes
Desc: not available
Url : http://developer.classpath.org/pipermail/classpath-patches/attachments/20060615/ca32dae4/startup-synch.bin
More information about the Classpath-patches