mutex_lock(&(waitingthread->waitmutex));
- DEBUGLOCKS(("[lock_record_notify: lr=%p, t=%p, waitingthread=%p, sleeping=%d, one=%d]",
- lr, t, waitingthread, waitingthread->sleeping, one));
+ DEBUGLOCKS(("[lock_record_notify: lr=%p, t=%p, waitingthread=%p, one=%d]",
+ lr, t, waitingthread, one));
- /* Signal the thread if it's sleeping. sleeping can be false
- when the waiting thread is blocked between giving up the
- monitor and entering the waitmutex. It will eventually
- observe that it's signaled and refrain from going to
- sleep. */
-
- if (waitingthread->sleeping)
- pthread_cond_signal(&(waitingthread->waitcond));
+ pthread_cond_signal(&(waitingthread->waitcond));
/* Mark the thread as signaled. */
t->interrupted = false;
t->signaled = false;
- t->sleeping = false;
t->suspended = false;
t->suspend_reason = 0;
mutex_lock(&t->waitmutex);
- /* mark us as sleeping */
-
- t->sleeping = true;
-
/* wait on waitcond */
if (wakeupTime->tv_sec || wakeupTime->tv_nsec) {
}
}
- t->sleeping = false;
-
/* release the waitmutex */
mutex_unlock(&t->waitmutex);
pthread_kill(thread->tid, SIGHUP);
- if (thread->sleeping)
- pthread_cond_signal(&thread->waitcond);
+ pthread_cond_signal(&thread->waitcond);
thread->interrupted = true;
inline static bool thread_is_interrupted(threadobject *t)
{
- return t->interrupted;
+ bool interrupted;
+
+ /* We need the mutex because classpath will call this function when
+ a blocking system call is interrupted. The mutex ensures that it will
+ see the correct value for the interrupted flag. */
+
+ mutex_lock(&t->waitmutex);
+ interrupted = t->interrupted;
+ mutex_unlock(&t->waitmutex);
+
+ return interrupted;
}