[vmkit-commits] [vmkit] r78186 - /vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Wed Aug 5 02:58:34 PDT 2009


Author: geoffray
Date: Wed Aug  5 04:58:03 2009
New Revision: 78186

URL: http://llvm.org/viewvc/llvm-project?rev=78186&view=rev
Log:
Start looking at offset 0 instead of last offset when looking for a stack, so
that we don't end up using all the virtual memory mapped for thread stacks.


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=78186&r1=78185&r2=78186&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Wed Aug  5 04:58:03 2009
@@ -112,19 +112,18 @@
 
   uintptr_t allocate() {
     stackLock.lock();
-    uint32 start = allocPtr;
     uint32 myIndex = 0;
     do {
-      if (!used[allocPtr]) {
-        used[allocPtr] = 1;
-        myIndex = allocPtr;
+      if (!used[myIndex]) {
+        used[myIndex] = 1;
+        break;
       }
-      if (++allocPtr == NR_THREADS) allocPtr = 0;
-    } while (!myIndex && allocPtr != start);
+      ++myIndex;
+    } while (myIndex != NR_THREADS);
   
     stackLock.unlock();
     
-    if (myIndex)
+    if (myIndex != NR_THREADS)
       return baseAddr + myIndex * STACK_SIZE;
 
     return 0;





More information about the vmkit-commits mailing list