changes...make it actually do the gc's...
authorbdemsky <bdemsky>
Thu, 30 Jun 2011 20:51:30 +0000 (20:51 +0000)
committerbdemsky <bdemsky>
Thu, 30 Jun 2011 20:51:30 +0000 (20:51 +0000)
Robust/src/Runtime/mem.c

index 1e2e1a5f64985143f516344a0c99f94878881382..7490bb6f0e433443638ed9e6c4613035f4ef6962 100644 (file)
@@ -15,31 +15,31 @@ void * mycalloc_share(struct garbagelist * stackptr, int size) {
   void * p = NULL;
   int isize = ((size-1)&(~(ALIGNMENTSIZE-1)))+ALIGNMENTSIZE;
   int hasgc = 0;
+  int loopcount = 0;
 
-  while(true) {
-    if(gcflag) {
-      gc(stackptr);
-    }
+  while(loopcount<10000) {
     p = BAMBOO_SHARE_MEM_CALLOC(isize); // calloc(m, isize);
 
-    if(p == NULL) {
-      // no more global shared memory
-      if(hasgc < 5) {
-       // start gc
-       if(gcflag) {
-         gc(stackptr);
-       }
+    if(p != NULL) 
+      return p;
+    
+    // no more global shared memory
+    if(hasgc < 5) {
+      // start gc
+      if(gcflag) {
+       gc(stackptr);
        hasgc++;
-      } else {
-       // no more global shared memory
-       BAMBOO_EXIT();
       }
-    } else
-      break;
+    } else {
+      // no more global shared memory
+      printf("Did %u collections without getting memory\n", hasgc);
+      BAMBOO_EXIT();
+    }
   }
-  
-  return p;
+  tprint("Loopcount hit 10000\n");
+  BAMBOO_EXIT();
 }
+
 #else
 void * mycalloc_share(int size) {
   int isize = ((size-1)&(~(BAMBOO_CACHE_LINE_MASK)))+(BAMBOO_CACHE_LINE_SIZE);