[vmkit-commits] [vmkit] r114295 - /vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sat Sep 18 12:10:36 PDT 2010
Author: geoffray
Date: Sat Sep 18 14:10:35 2010
New Revision: 114295
URL: http://llvm.org/viewvc/llvm-project?rev=114295&view=rev
Log:
Do a yield loop when trying to allocate a thread.
Modified:
vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp?rev=114295&r1=114294&r2=114295&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Sat Sep 18 14:10:35 2010
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+#include "debug.h"
+
#include "MvmGC.h"
#include "mvm/VirtualMachine.h"
#include "mvm/Threads/Cond.h"
@@ -336,9 +338,13 @@
assert(sz < (size_t)getpagesize() && "Thread local data too big");
void* res = (void*)TheStackManager.allocate();
// Give it a second chance.
- if (!res) {
+ if (res == NULL) {
Collector::collect();
- res = (void*)TheStackManager.allocate();
+ // Wait for the finalizer to have cleaned up the threads.
+ while (res == NULL) {
+ mvm::Thread::yield();
+ res = (void*)TheStackManager.allocate();
+ }
}
return res;
}
More information about the vmkit-commits
mailing list