lots of bugs...garbage collection/checkpointing/etc
authorbdemsky <bdemsky>
Mon, 26 Feb 2007 22:36:00 +0000 (22:36 +0000)
committerbdemsky <bdemsky>
Mon, 26 Feb 2007 22:36:00 +0000 (22:36 +0000)
Robust/src/Benchmarks/WebServer/Inventory.java
Robust/src/Benchmarks/WebServer/WebServerExample.java
Robust/src/Benchmarks/WebServer/Workload/batch/run2.sh
Robust/src/Runtime/checkpoint.c
Robust/src/Runtime/garbage.c
Robust/src/Runtime/runtime.c

index 6964a18e4493833709fd011f15d9b11969a2a656..74756956310539eea53026cf09aabf1ce6aa7e78 100644 (file)
@@ -61,28 +61,31 @@ public class Inventory {
     }
 
     //Display the inventory list
-    public String inventory(){
-       HashMapIterator i = new HashMapIterator(map, 0);// Gets key from the hashmap= name of item
-       HashMapIterator j = new HashMapIterator(map, 1);//Gets the value from hashmap 
-       StringBuffer sb = new StringBuffer("");
+    //Display the inventory list
+    public synchronized void inventory(Socket s){
+        HashMapIterator i = new HashMapIterator(map, 0);// Gets key from the hashmap= name of item
+        HashMapIterator j = new HashMapIterator(map, 1);//Gets the value from hashmap 
        int totalvalue=balance;
-       while (i.hasNext() == true) {
-           Object o = i.next();
-           String name = o.toString();
-           ItemInfo oo = (ItemInfo) j.next();
-           sb.append(name);
-           sb.append(" ");
-           Integer q = new Integer(oo.quantity);
-           sb.append(q.toString());
-           sb.append(" ");
-           Integer p = new Integer(oo.price);
-           sb.append(p.toString());
-           sb.append("\n");
-           totalvalue+=oo.quantity*oo.price;
-       }
-       sb.append("Total value: ");
-       sb.append((new Integer(totalvalue)).toString());
-       sb.append("\n");
-       return sb.toString();   
-    }  
+        while (i.hasNext() == true) {
+            StringBuffer sb = new StringBuffer("");
+            Object o = i.next();
+            String name = o.toString();
+            ItemInfo oo = (ItemInfo) j.next();
+            sb.append(name);
+            sb.append(" ");
+            Integer q = new Integer(oo.quantity);
+            sb.append(q.toString());
+            sb.append(" ");
+            Integer p = new Integer(oo.price);
+            sb.append(p.toString());
+            sb.append("\n");
+            totalvalue+=oo.quantity*oo.price;
+            s.write(sb.toString().getBytes());
+        }
+        StringBuffer sb=new StringBuffer("");
+        sb.append("Total value: ");
+        sb.append((new Integer(totalvalue)).toString());
+        sb.append("\n");
+        s.write(sb.toString().getBytes());
+    }   
 }
index e4ace258709f1b9321578a183352aa34f1b0494c..664465a55d31bdabe302cea6d0c6f0df4b150f4b 100644 (file)
@@ -101,8 +101,7 @@ task Transaction(WebServerSocket web{TransPending}, Inventory inventorylist{Tran
        } else if (op == 2) { /* Inventory */
 //             System.printString("DEBUG > Calling inventory transaction\n");
                web.httpresponse();
-               String towrite = inventorylist.inventory();     
-               web.write(towrite.getBytes());
+               inventorylist.inventory(web);   
        } else { /* Error */ 
 //             System.printString("T > Error - Unknown transaction\n");
        }
index c96b19a17a4d6a9993be4506a8e6ff3131f0b0da..672780b0b6c3afe38922bcb95c845068707788f3 100755 (executable)
@@ -7,7 +7,7 @@ rm output #Errors and total number of run count are redirected to this file
 #Sets the BRISTLECONE parameter with a certain instruction count, probability and 
 #number of failures that can be injected
 #export BRISTLECONE="-initializerandom -injectinstructionfailures 10 0.00001667 1 -debugtask"
-export BRISTLECONE="-initializerandom -injectinstructionfailures 35 0.00001667 50 -debugtask"
+export BRISTLECONE="-initializerandom -injectinstructionfailures 35 0.00001667 50"
 rm -rf results
 mkdir results
 cd results
index df66337d84b27190db2bf7fef8adef0b44511186..d7556a721545274d9d4269165dc0b4269abc3054 100644 (file)
@@ -154,16 +154,21 @@ void * createcopy(void * orig) {
 
 void restorecheckpoint(int numparams, void ** original, void ** checkpoint, struct RuntimeHash *forward, struct RuntimeHash * reverse) {
   struct RuntimeHash *todo=allocateRuntimeHash(100);
+  struct RuntimeHash *visited=allocateRuntimeHash(100);
   int i;
 
   for(i=0;i<numparams;i++) {
-    RuntimeHashadd(todo, (int) checkpoint[i], (int) checkpoint[i]);
+    if (checkpoint[i]!=NULL) {
+      RuntimeHashadd(todo, (int) checkpoint[i], (int) checkpoint[i]);
+      RuntimeHashadd(visited, (int) checkpoint[i], (int) checkpoint[i]);
+    }
   }
-
+  
   while(RuntimeHashcountset(todo)!=0) {
     void * ptr=(void *) RuntimeHashfirstkey(todo);
     int type=((int *)ptr)[0];
     RuntimeHashremove(todo, (int) ptr, (int) ptr);
+
     {
       void *cpy;
       int *pointer;
@@ -192,8 +197,13 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru
          void *objptr=((void **)(((char *)& ao->___length___)+sizeof(int)))[i];
          if (objptr==NULL)
            ((void **)(((char *)& ao_cpy->___length___)+sizeof(int)))[i]=NULL;
-         else
+         else {
+           if (!RuntimeHashcontainskey(visited, (int) objptr)) {
+             RuntimeHashadd(visited, (int) objptr, (int) objptr);
+             RuntimeHashadd(todo, (int) objptr, (int) objptr);
+           }
            RuntimeHashget(reverse, (int) objptr, (int *) &((void **)(((char *)& ao_cpy->___length___)+sizeof(int)))[i]);
+         }
        }
       } else {
        int numptr=pointer[0];
@@ -208,8 +218,13 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru
          void * objptr=*((void **)(((int)ptr)+offset));
          if (objptr==NULL)
            *((void **) (((int)cpy)+offset))=NULL;
-         else
+         else {
+           if (!RuntimeHashcontainskey(visited, (int) objptr)) {
+             RuntimeHashadd(visited, (int) objptr, (int) objptr);
+             RuntimeHashadd(todo, (int) objptr, (int) objptr);
+           }
            RuntimeHashget(reverse, (int) objptr, (int *) &(((char *)cpy)[offset]));
+         }
        }
        if (hasflags[type]) {
          (((void **)cpy)[2])=flagptr;
@@ -219,4 +234,5 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru
     }
   }
   freeRuntimeHash(todo);
+  freeRuntimeHash(visited);
 }
index 405cb872f6fc5424f9160809043f3139d7e30d1a..69f32a6a35ea3ac74dded56795ff868cd29099ee 100644 (file)
@@ -24,6 +24,7 @@
 extern struct Queue * activetasks;
 extern struct parameterwrapper * objectqueues[NUMCLASSES];
 extern struct genhashtable * failedtasks;
+extern struct taskparamdescriptor *currtpd;
 extern struct RuntimeHash *forward;
 extern struct RuntimeHash *reverse;
 extern struct RuntimeHash *fdtoobject;
@@ -194,6 +195,18 @@ void collect(struct garbagelist * stackptr) {
     }
   }
 
+  {
+    /* Update current task descriptor */
+    int i;
+    for(i=0;i<currtpd->numParameters;i++) {
+      void *orig=currtpd->parameterArray[i];
+      void *copy;
+      if (gc_createcopy(orig, &copy))
+       enqueue(orig);
+      currtpd->parameterArray[i]=copy;
+    }
+
+  }
 
   {
     /* Update active tasks */
@@ -216,11 +229,10 @@ void collect(struct garbagelist * stackptr) {
     struct genpointerlist * ptr=failedtasks->list;
     while(ptr!=NULL) {
       struct taskparamdescriptor *tpd=ptr->src;
-      void *orig;
-      void *copy;
       int i;
       for(i=0;i<tpd->numParameters;i++) {
-       orig=tpd->parameterArray[i];
+       void * orig=tpd->parameterArray[i];
+       void * copy;
        if (gc_createcopy(orig, &copy))
          enqueue(orig);
        tpd->parameterArray[i]=copy;
index 1d5d35e13b493c1551eda5b11eb7d73b171b1acb..3f717db1aadcfad9dbddfea165ed5de45dffcd9f 100644 (file)
@@ -41,6 +41,7 @@ int instaccum=0;
 struct Queue * activetasks;
 struct parameterwrapper * objectqueues[NUMCLASSES];
 struct genhashtable * failedtasks;
+struct taskparamdescriptor * currtpd;
 struct RuntimeHash * forward;
 struct RuntimeHash * reverse;
 
@@ -120,10 +121,12 @@ int comparetpd(struct taskparamdescriptor *ftd1, struct taskparamdescriptor *ftd
    with the or mask and and's it with the andmask. */
 
 void flagorand(void * ptr, int ormask, int andmask) {
-  int flag=((int *)ptr)[1];
+  int oldflag=((int *)ptr)[1];
   struct RuntimeHash *flagptr=(struct RuntimeHash *)(((int*)ptr)[2]);
-  flag|=ormask;
+  int flag=ormask|oldflag;
   flag&=andmask;
+  if (flag==oldflag) /* Don't do anything */
+    return;
   ((int*)ptr)[1]=flag;
 
   /*Remove object from all queues */
@@ -182,7 +185,11 @@ void flagorand(void * ptr, int ormask, int andmask) {
              /* Queue task */
              if (!gencontains(failedtasks, tpd))
                addNewItem(activetasks, tpd);
-             
+             else {
+               RUNFREE(tpd->parameterArray);
+               RUNFREE(tpd);
+             }
+
              /* This loop iterates to the next parameter combination */
              for(j=0;j<numparams;j++) {
                if (j==newindex) {
@@ -261,6 +268,7 @@ void executetasks() {
   sigaction(SIGBUS,&sig,0);
   sigaction(SIGSEGV,&sig,0);
   sigaction(SIGFPE,&sig,0);
+  sigaction(SIGPIPE,&sig,0);
 
   /* Zero fd set */
   FD_ZERO(&readfds);
@@ -300,27 +308,34 @@ void executetasks() {
     if (!isEmpty(activetasks)) {
       int i;
       struct QueueItem * qi=(struct QueueItem *) getTail(activetasks);
-      struct taskparamdescriptor *tpd=(struct taskparamdescriptor *) qi->objectptr;
+      currtpd=(struct taskparamdescriptor *) qi->objectptr;
       removeItem(activetasks, qi);
 
       /* Check if this task has failed */
-      if (gencontains(failedtasks, tpd))
+      if (gencontains(failedtasks, currtpd)) {
+       // Free up task parameter descriptor
+       RUNFREE(currtpd->parameterArray);
+       RUNFREE(currtpd);
        goto newtask;
+      }
       
       /* Make sure that the parameters are still in the queues */
-      for(i=0;i<tpd->task->numParameters;i++) {
-       void * parameter=tpd->parameterArray[i];
-       struct parameterdescriptor * pd=tpd->task->descriptorarray[i];
+      for(i=0;i<currtpd->task->numParameters;i++) {
+       void * parameter=currtpd->parameterArray[i];
+       struct parameterdescriptor * pd=currtpd->task->descriptorarray[i];
        struct parameterwrapper *pw=(struct parameterwrapper *) pd->queue;
-       if (!RuntimeHashcontainskey(pw->objectset, (int) parameter))
+       if (!RuntimeHashcontainskey(pw->objectset, (int) parameter)) {
+         RUNFREE(currtpd->parameterArray);
+         RUNFREE(currtpd);
          goto newtask;
+       }
        taskpointerarray[i+OFFSET]=parameter;
       }
       {
        /* Checkpoint the state */
        forward=allocateRuntimeHash(100);
        reverse=allocateRuntimeHash(100);
-       void ** checkpoint=makecheckpoint(tpd->task->numParameters, &taskpointerarray[OFFSET], forward, reverse);
+       void ** checkpoint=makecheckpoint(currtpd->task->numParameters, currtpd->parameterArray, forward, reverse);
        int x;
        if (x=setjmp(error_handler)) {
          /* Recover */
@@ -328,8 +343,8 @@ void executetasks() {
 #ifdef DEBUG
          printf("Fatal Error=%d, Recovering!\n",x);
 #endif
-         genputtable(failedtasks,tpd,tpd);
-         restorecheckpoint(tpd->task->numParameters, &taskpointerarray[OFFSET], checkpoint, forward, reverse);
+         genputtable(failedtasks,currtpd,currtpd);
+         restorecheckpoint(currtpd->task->numParameters, currtpd->parameterArray, checkpoint, forward, reverse);
          freeRuntimeHash(forward);
          freeRuntimeHash(reverse);
          freemalloc();
@@ -338,25 +353,28 @@ void executetasks() {
        } else {
          if (injectfailures) {
            if ((((double)random())/RAND_MAX)<failurechance) {
-             printf("\nINJECTING TASK FAILURE to %s\n", tpd->task->name);
+             printf("\nINJECTING TASK FAILURE to %s\n", currtpd->task->name);
              longjmp(error_handler,10);
            }
          }
          /* Actually call task */
 #ifdef PRECISE_GC
-         ((int *)taskpointerarray)[0]=tpd->task->numParameters;
+         ((int *)taskpointerarray)[0]=currtpd->task->numParameters;
          taskpointerarray[1]=NULL;
 #endif
 
          if (debugtask) {
-           printf("ENTER %s count=%d\n",tpd->task->name, (instaccum-instructioncount));
-           ((void (*) (void **)) tpd->task->taskptr)(taskpointerarray);
-           printf("EXIT %s count=%d\n",tpd->task->name, (instaccum-instructioncount));
+           printf("ENTER %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
+           ((void (*) (void **)) currtpd->task->taskptr)(taskpointerarray);
+           printf("EXIT %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
          } else
-           ((void (*) (void **)) tpd->task->taskptr)(taskpointerarray);
+           ((void (*) (void **)) currtpd->task->taskptr)(taskpointerarray);
          freeRuntimeHash(forward);
          freeRuntimeHash(reverse);
          freemalloc();
+         // Free up task parameter descriptor
+         RUNFREE(currtpd->parameterArray);
+         RUNFREE(currtpd);
          forward=NULL;
          reverse=NULL;
        }