Re: [Sablevm-developer] Thread.interrupted() TROUBLES
Brought to you by:
egagnon
From: Grzegorz B. P. <ga...@de...> - 2004-03-09 05:55:59
|
Hi again, Today I discussed the implementation with Etienne, and corrected it a bit. But I was terribly surprised when later it completly didn't work. What's more interesting - the code that worked yesterday - now also doesn't work! (test case java class attached) What has changed is that apparently sending SIGUSR1 to a thread blocked in pthread_cond_timedwait does NOT wake it up (anymore?)! Manual page still says this: The pthread_cond_timedwait function returns the following error codes on error: ETIMEDOUT - the condition variable was not signaled until the timeout specified by |abstime| EINTR - pthread_cond_timedwait was interrupted by a signal So I thought there's some new bug after upgrades I did yesterday... but http://www.opengroup.org/onlinepubs/007904975/functions/pthread_cond_wait.html says: "If a signal is delivered to a thread waiting for a condition variable, upon return from the signal handler the thread resumes waiting for the condition variable as if it was not interrupted, or it shall return zero due to spurious wakeup." and later: "These functions shall not return an error code of [EINTR]." So it looks like for each thread we would need to store information where it currently is waiting (if anywhere) and if needed - signal such thread to unblock (or rather all of the waiting threads). These two look promising, though I think it's more logical to use ..._broadcast(). int pthread_cond_broadcast(pthread_cond_t *cond); int pthread_cond_signal(pthread_cond_t *cond); I'll try to implement that tomorrow but if anybody has better idea, or some advices, I'll be glad to hear. eh, TANSTAAFL... Cheers, Grzegorz B. Prokopski -- Grzegorz B. Prokopski <ga...@de...> Debian GNU/Linux http://www.debian.org SableVM - LGPLed JVM http://www.sablevm.org Why SableVM ?!? http://devel.sablevm.org/wiki/WhySableVM |