You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by wj...@apache.org on 2007/03/03 22:42:35 UTC
svn commit: r514249 - in /harmony/enhanced/drlvm/trunk/vm:
thread/src/thread_init.c vmcore/src/class_support/C_Interface.cpp
Author: wjwashburn
Date: Sat Mar 3 13:42:34 2007
New Revision: 514249
URL: http://svn.apache.org/viewvc?view=rev&rev=514249
Log:
H3203, fixes deadlock in vm_gc_lock_enum
build, build test passes on winxp 32 and linux rhel4.0 32 gcc 4.0.2
Modified:
harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c
harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c?view=diff&rev=514249&r1=514248&r2=514249
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c Sat Mar 3 13:42:34 2007
@@ -229,7 +229,38 @@
* The lock blocks new thread creation and thread exit operations.
*/
IDATA VMCALL hythread_global_lock() {
- return hymutex_lock(TM_LIBRARY->TM_LOCK);
+ IDATA r = 0;
+ hythread_t self = tm_self_tls;
+ int saved_count;
+
+ // we need not care about suspension if the thread
+ // is not even tattached to hythread
+ if (self == NULL)
+ return hymutex_lock(TM_LIBRARY->TM_LOCK);
+
+ // suspend_disable_count must be 0 on potentially
+ // blocking operation to prevent suspension deadlocks,
+ // meaning that the thread is safe for suspension
+ saved_count = reset_suspend_disable();
+ r = hymutex_lock(TM_LIBRARY->TM_LOCK);
+ if (r) return r;
+
+ // make sure we do not get a global thread lock
+ // while being requested to suspend
+ while (self->suspend_request) {
+ // give up global thread lock before safepoint,
+ // because this thread can be suspended at a safepoint
+ r = hymutex_unlock(TM_LIBRARY->TM_LOCK);
+ if (r) return r;
+ hythread_safe_point();
+ r = hymutex_lock(TM_LIBRARY->TM_LOCK);
+ if (r) return r;
+ }
+
+ // do not use set_suspend_disable() as we do not
+ // want safe points happening under global lock
+ self->suspend_disable_count = saved_count;
+ return 0;
}
/**
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp?view=diff&rev=514249&r1=514248&r2=514249
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp Sat Mar 3 13:42:34 2007
@@ -2296,9 +2296,7 @@
void vm_gc_lock_enum()
{
- tmn_suspend_enable();
hythread_global_lock();
- tmn_suspend_disable();
} // vm_gc_lock_enum