Merged to new trunk.
authorStefan Ring <stefan@complang.tuwien.ac.at>
Sun, 15 Jun 2008 09:10:15 +0000 (11:10 +0200)
committerStefan Ring <stefan@complang.tuwien.ac.at>
Sun, 15 Jun 2008 09:10:15 +0000 (11:10 +0200)
src/threads/posix/lock.c
src/threads/posix/thread-posix.c
src/threads/posix/thread-posix.h
src/threads/thread.h
src/vm/signal.c

index 4d69503ba8a2824b904c0a5d11aa26a2f872b271..71e5a0077132212fb2704d721e2057344bf81e7b 100644 (file)
@@ -1418,17 +1418,10 @@ static void lock_record_notify(threadobject *t, lock_record_t *lr, bool one)
 
                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. */
 
index 26002bc5b25101bebe986732689d07d85e00b152..cfa6deca7de49c11052d1257b6355caed1796132 100644 (file)
@@ -723,7 +723,6 @@ void threads_impl_thread_clear(threadobject *t)
 
        t->interrupted = false;
        t->signaled = false;
-       t->sleeping = false;
 
        t->suspended = false;
        t->suspend_reason = 0;
@@ -1648,10 +1647,6 @@ static void threads_wait_with_timeout(threadobject *t, struct timespec *wakeupTi
 
        mutex_lock(&t->waitmutex);
 
-       /* mark us as sleeping */
-
-       t->sleeping = true;
-
        /* wait on waitcond */
 
        if (wakeupTime->tv_sec || wakeupTime->tv_nsec) {
@@ -1678,8 +1673,6 @@ static void threads_wait_with_timeout(threadobject *t, struct timespec *wakeupTi
                }
        }
 
-       t->sleeping    = false;
-
        /* release the waitmutex */
 
        mutex_unlock(&t->waitmutex);
@@ -1770,8 +1763,7 @@ void threads_thread_interrupt(threadobject *thread)
 
        pthread_kill(thread->tid, SIGHUP);
 
-       if (thread->sleeping)
-               pthread_cond_signal(&thread->waitcond);
+       pthread_cond_signal(&thread->waitcond);
 
        thread->interrupted = true;
 
index 40f7fcd02528ad9937190a7d3ca9c67cf8666138..45d05eca4407779363f6c553befb969e35141446 100644 (file)
@@ -138,7 +138,6 @@ struct threadobject {
 
        bool                  interrupted;
        bool                  signaled;
-       bool                  sleeping;
 
        bool                  suspended;    /* is this thread suspended?          */
        s4                    suspend_reason; /* reason for suspending            */
index 61ddbfd8a4dd6556fa4c6d314026b9ae73e1d32e..309de1a9bc9d4d7216b14d154f67355f56a04393 100644 (file)
@@ -206,7 +206,17 @@ inline static bool thread_is_attached(threadobject *t)
 
 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;
 }
 
 
index f11a67bc6dabfeea24f6fa7d76deb7bbc753b53c..5cdd0ed3ae7bf0327220b860369661b6b98e0b3f 100644 (file)
@@ -304,7 +304,7 @@ void signal_thread_handler(int sig)
        case SIGINT:
                /* exit the vm properly */
 
-               vm_exit(0);
+               vm_exit(1);
                break;
 
        case SIGQUIT: