[vmkit-commits] [vmkit] r87038 - in /vmkit/trunk: include/mvm/Threads/CollectionRV.h lib/Mvm/CommonThread/CollectionRV.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Thu Nov 12 14:38:52 PST 2009


Author: geoffray
Date: Thu Nov 12 16:38:52 2009
New Revision: 87038

URL: http://llvm.org/viewvc/llvm-project?rev=87038&view=rev
Log:
Fix deadlock when a GC was happening before a thread was released from previous GC.


Modified:
    vmkit/trunk/include/mvm/Threads/CollectionRV.h
    vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp

Modified: vmkit/trunk/include/mvm/Threads/CollectionRV.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/CollectionRV.h?rev=87038&r1=87037&r2=87038&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/Threads/CollectionRV.h (original)
+++ vmkit/trunk/include/mvm/Threads/CollectionRV.h Thu Nov 12 16:38:52 2009
@@ -62,8 +62,8 @@
   }
 
   void cancelRV() {
-    mvm::Thread::get()->inRV = false;
     unlockRV();
+    mvm::Thread::get()->inRV = false;
   }
  
   void finishRV();

Modified: vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp?rev=87038&r1=87037&r2=87038&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp Thu Nov 12 16:38:52 2009
@@ -109,17 +109,23 @@
   }
 
   assert(th->getLastSP() && "Joined without giving a SP");
-  // Wait for the rendezvous to finish.
-  waitEndOfRV();
   
-  // The rendezvous is finished. Set inRV to false.
-  th->inRV = false;
+  do {
+    // Wait for the rendezvous to finish.
+    waitEndOfRV();
+    // If we wake up here and doYield is set, this means that a new GC is
+    // happening, so join it.
+  } while (th->doYield);
+  
   if (changed) th->setLastSP(0);
  
   // Unlock after modifying lastSP, because lastSP is also read by the
   // rendezvous initiator.
   unlockRV();
   
+  // The rendezvous is finished. Set inRV to false.
+  th->inRV = false;
+  
 }
 
 extern "C" void conditionalSafePoint() {





More information about the vmkit-commits mailing list