harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r597678 - in /harmony/enhanced/drlvm/trunk/vm: thread/src/thread_native_basic.c thread/src/thread_native_park.c vmcore/src/kernel_classes/javasrc/java/lang/Thread.java
Date Fri, 23 Nov 2007 15:11:45 GMT
Author: gshimansky
Date: Fri Nov 23 07:11:45 2007
New Revision: 597678

URL: http://svn.apache.org/viewvc?rev=597678&view=rev
Log:
Applied patch from HARMONY-5164
[drlvm][thread] join should not call notifyAll on thread instance.


Modified:
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c?rev=597678&r1=597677&r2=597678&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c Fri Nov 23 07:11:45 2007
@@ -411,6 +411,11 @@
     thread->state &= ~TM_THREAD_STATE_SLEEPING;
     hymutex_unlock(&thread->mutex);
 
+    if (thread->request) {
+        hythread_safe_point();
+        hythread_exception_safe_point();
+    }
+
     return (status == TM_ERROR_INTERRUPT && interruptable) ? TM_ERROR_INTERRUPT :
TM_ERROR_NONE;
 }
 
@@ -838,6 +843,21 @@
     // so that it would eventually reach exception safepoint
     // and execute callback
     hysem_post(thread->resume_event);
+
+    if (thread->state &
+            (TM_THREAD_STATE_SLEEPING | TM_THREAD_STATE_WAITING_WITH_TIMEOUT
+                | TM_THREAD_STATE_WAITING | TM_THREAD_STATE_IN_MONITOR_WAIT
+                | TM_THREAD_STATE_WAITING_INDEFINITELY | TM_THREAD_STATE_PARKED))
+    {
+        // This is needed for correct stopping of a thread blocked on monitor_wait.
+        // The thread needs some flag to exit its waiting loop.
+        // We piggy-back on interrupted status. A correct exception from TLS
+        // will be thrown because the check of exception status on leaving
+        // JNI frame comes before checking return status in Object.wait().
+        // Interrupted status will be cleared by function returning TM_ERROR_INTERRUPT.
+        // (though, in case of parked thread, it will not be cleared)
+        hythread_interrupt(thread);
+    }
     return status;
 } // hythread_set_thread_stop_callback
 

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c?rev=597678&r1=597677&r2=597678&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c Fri Nov 23 07:11:45 2007
@@ -58,6 +58,16 @@
      status = hycond_wait_interruptable(&t->condition, &t->mutex, millis, nanos);
      t->state &= ~TM_THREAD_STATE_PARKED;
 
+     if (t->request) {
+         int save_count;
+         hymutex_unlock(&t->mutex);
+         hythread_safe_point();
+         hythread_exception_safe_point();
+         save_count = hythread_reset_suspend_disable();
+         hymutex_lock(&t->mutex);
+         hythread_set_suspend_disable(save_count);
+     }
+
      //the status should be restored for j.u.c.LockSupport
      if (status == TM_ERROR_INTERRUPT) {
          t->state |= TM_THREAD_STATE_INTERRUPTED;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java?rev=597678&r1=597677&r2=597678&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java
Fri Nov 23 07:11:45 2007
@@ -587,7 +587,6 @@
      * @com.intel.drl.spec_ref
      */
     public final synchronized void join() throws InterruptedException {
-        notifyAll();
         while (isAlive()) {
             wait();
         }
@@ -600,7 +599,6 @@
         if (millis == 0) {
             join();
         } else {
-            notifyAll();
             long end = System.currentTimeMillis() + millis;
             while(isAlive()) {
                 wait(millis);
@@ -622,7 +620,6 @@
         } else if (millis == 0 && nanos == 0) {
             join();
         } else {
-            notifyAll();
             long end = System.nanoTime() + 1000000*millis + (long)nanos;
             long rest;
             while (isAlive()) {



Mime
View raw message