Patch [ecj]: Fix cross-configury issues / compile ecj.jar for non-shared builds
Andrew Haley
aph@redhat.com
Thu Dec 7 11:14:00 GMT 2006
Mohan Embar writes:
>
> I'm feeling a bit burned out, so I'm not going to get to fixing
> this up:
>
> http://gcc.gnu.org/ml/java-patches/2006-q4/msg00209.html
>
> ...right away. (See the followups for Andrew's feedback.)
> If anyone (<cough>Adam</cough>) wants to take this from me,
> be my guest. Otherwise, I'll get to it next week or so.
Fair enough. The Linux code is more complicated than it needs to be,
anyway. What we really need, rather than imitating the Linux code, is
the best Windows-specific way to do it.
>From what I can determine by scanning the net, this is probably a call
to WaitForSingleObject() in park() and a call to SetEvent() in
unpark(). (See
http://www.codersource.net/win32_waitforsingleobject.html,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/waitforsingleobject.asp.)
It doesn't have to be anything more complicated than that.
So, apart from the timer code, park() and unpark() may be as simple as
this:
void
_Jv_ThreadPark (jboolean isAbsolute, jlong time)
{
/* ... */
/* If we have a permit, return immediately. */
if (compare_and_swap
(ptr, Thread::THREAD_PARK_PERMIT, Thread::THREAD_PARK_RUNNING))
return;
/* ... */
if (compare_and_swap
(ptr, Thread::THREAD_PARK_RUNNING, Thread::THREAD_PARK_PARKED))
{
WaitForSingleObject (nt->park_event, millis);
/* If we were unparked by some other thread, this will already
be in state THREAD_PARK_RUNNING. If we timed out, we have to
do it ourself. */
compare_and_swap
(ptr, Thread::THREAD_PARK_PARKED, Thread::THREAD_PARK_RUNNING);
}
}
void
_Jv_ThreadUnpark (::java::lang::Thread *thread)
{
/* ... */
/* If this thread is in state RUNNING, give it a permit and return
immediately. */
if (compare_and_swap
(ptr, Thread::THREAD_PARK_RUNNING, Thread::THREAD_PARK_PERMIT))
return;
/* If this thread is parked, put it into state RUNNING and send it a
signal. */
if (compare_and_swap
(ptr, Thread::THREAD_PARK_PARKED, Thread::THREAD_PARK_RUNNING))
{
SetEvent (nt->park_event);
}
}
Andrew.
More information about the Java-patches
mailing list