You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2008/01/30 19:38:41 UTC

svn commit: r616837 - in /harmony/enhanced/drlvm/trunk/vm: tests/unit/thread/test_ti_raw_monitors.c vmcore/src/thread/thread_ti_monitors.cpp

Author: gshimansky
Date: Wed Jan 30 10:38:32 2008
New Revision: 616837

URL: http://svn.apache.org/viewvc?rev=616837&view=rev
Log:
Applied patch from HARMONY-5408
[drlvm][jdwp] tests stress.org.apache.harmony.test.stress.jpda.jdwp.scenario.THREAD hungs


Modified:
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_raw_monitors.c
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_monitors.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_raw_monitors.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_raw_monitors.c?rev=616837&r1=616836&r2=616837&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_raw_monitors.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_raw_monitors.c Wed Jan 30 10:38:32 2008
@@ -167,7 +167,7 @@
     reset_tested_thread_iterator(&tts);
     while(next_tested_thread(&tts)){
         count = 0;
-        while (!hythread_is_waiting(tts->native_thread)) {
+        while (tts->phase != TT_PHASE_WAITING_ON_WAIT) {
             // wait until the state is changed
             hythread_sleep(SLEEP_TIME);
             if (tts->phase == TT_PHASE_ERROR || ++count > (MAX_TIME_TO_WAIT/SLEEP_TIME)) {
@@ -242,7 +242,7 @@
     reset_tested_thread_iterator(&tts);
     while(next_tested_thread(&tts)){
         count = 0;
-        while (!hythread_is_waiting(tts->native_thread)) {
+        while (tts->phase != TT_PHASE_WAITING_ON_WAIT) {
             // wait until the state is changed
             hythread_sleep(SLEEP_TIME);
             if (tts->phase == TT_PHASE_ERROR || ++count > (MAX_TIME_TO_WAIT/SLEEP_TIME)) {

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_monitors.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_monitors.cpp?rev=616837&r1=616836&r2=616837&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_monitors.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_monitors.cpp Wed Jan 30 10:38:32 2008
@@ -297,42 +297,10 @@
     if (!monitor) {
         return TM_ERROR_INVALID_MONITOR;
     }
-
-    hythread_t native_thread = hythread_self();
-    IDATA hy_status = hythread_thread_lock(native_thread);
-    assert(hy_status == TM_ERROR_NONE);
-    IDATA state = hythread_get_state(native_thread);
-    state &= ~TM_THREAD_STATE_RUNNABLE;
-    state |= TM_THREAD_STATE_WAITING | TM_THREAD_STATE_IN_MONITOR_WAIT;
-    if (millis > 0) {
-        state |= TM_THREAD_STATE_WAITING_WITH_TIMEOUT;
-    }
-    else {
-        state |= TM_THREAD_STATE_WAITING_INDEFINITELY;
-    }
-    hy_status = hythread_set_state(native_thread, state);
-    assert(hy_status == TM_ERROR_NONE);
-    hythread_thread_unlock(native_thread);
-
-    IDATA status = hythread_monitor_wait_interruptable(monitor, millis, 0);
-
-    hy_status = hythread_thread_lock(native_thread);
-    assert(hy_status == TM_ERROR_NONE);
-    state = hythread_get_state(native_thread);
-    if (millis > 0) {
-        state &= ~TM_THREAD_STATE_WAITING_WITH_TIMEOUT;
-    }
-    else {
-        state &= ~TM_THREAD_STATE_WAITING_INDEFINITELY;
-    }
-    state &= ~(TM_THREAD_STATE_WAITING | TM_THREAD_STATE_IN_MONITOR_WAIT);
-    state |= TM_THREAD_STATE_RUNNABLE;
-    hy_status = hythread_set_state(native_thread, state);
-    assert(hy_status == TM_ERROR_NONE);
-    hy_status = hythread_thread_unlock(native_thread);
-    assert(hy_status == TM_ERROR_NONE);
-
-    return status;
+    // JDWP agent expects RawMonitor waiting thread has RUNNABLE state.
+    // That why no Java thread state change is done here.
+    // RI behaviour confirms this assumption.
+    return hythread_monitor_wait_interruptable(monitor, millis, 0);
 } // jthread_raw_monitor_wait
 
 /**