Changes to benchmarks
authorbdemsky <bdemsky>
Thu, 15 Mar 2007 08:07:06 +0000 (08:07 +0000)
committerbdemsky <bdemsky>
Thu, 15 Mar 2007 08:07:06 +0000 (08:07 +0000)
Small changes to runtime
Build binaries that exit upon SIGUSR2 so we can get output...

Robust/src/Benchmarks/Chat/ChatServer.java
Robust/src/Benchmarks/ChatJava/ChatThread.java
Robust/src/Benchmarks/WebServerJava/Inventory.java
Robust/src/Benchmarks/WebServerJava/Logger.java
Robust/src/ClassLibrary/String.java
Robust/src/Runtime/GenericHashtable.c
Robust/src/Runtime/checkpoint.c
Robust/src/Runtime/runtime.c
Robust/src/Runtime/runtime.h
Robust/src/Runtime/socket.c
Robust/src/Runtime/thread.c

index aed388ea46df1250d2f748107958ad467ec39428..50d256b92ca5c9f6abca37a689591e731eb7f186 100644 (file)
@@ -26,5 +26,10 @@ task Message(ChatSocket cs{InRoom && IOPending}) {
     byte buffer[]=new byte[1024];
     int length=cs.read(buffer);
     String st=(new String(buffer)).subString(0, length);
-    cs.room.sendToRoom(cs, st.getBytes());
+    Message m=new Message(st, cs){};
+}
+
+task SendMessage(Message m{!Sent}) {
+    m.cs.room.sendToRoom(m.cs,m.st.getBytes());
+    taskexit(m {Sent});
 }
index db533329fac3fa54a83ba67e293d499a6b72712a..7500abe9639af59c2e1e3f7c61445dabf27bef34 100644 (file)
@@ -30,10 +30,6 @@ public class ChatThread extends Thread {
        byte buffer[]=new byte[1024];
        int length=sock.read(buffer);
        String st=(new String(buffer)).subString(0, length);
-       System.printString(st);
-       System.printString("\n");
-       System.printInt(length);
-       System.printString("\n");
        room.sendToRoom(this, st.getBytes());
     }
     
index 7b6ee7c5a736775b94a734dd85016e09beb0ab1e..4c839535649ec4434551c31a845bd4abab4851ae 100644 (file)
@@ -1,7 +1,4 @@
 public class Inventory {
-    // Inventory flags
-    flag TransInitialize;
-    
     // Transaction variables
     int numitems;
     HashMap map;
index be29b3d3998778017135899581afc1e4fe32e538..9e7d3abaadeffbf36b9581680b73ed945c8f1f44 100644 (file)
@@ -1,6 +1,4 @@
 public class Logger {
-    //Logger flag
-    flag Initialize;
     FileOutputStream fos;
 
 
index 13798ff0bce81687d400ac2aaf831adb25d9965e..689d3cf9f2c28df5bfd1d5ebb2a6b1153eaf025b 100644 (file)
@@ -65,6 +65,17 @@ public class String {
        return -1;
     }
 
+    public String replace(char oldch, char newch) {
+       char[] buffer=new char[count];
+       for(int i=0;i<count;i++) {
+           char x=charAt(i);
+           if (x==oldch)
+               x=newch;
+           buffer[i]=x;
+       }
+       return new String(buffer);
+    }
+
     public int indexOf(int ch) {
        return this.indexOf(ch, 0);
     }
index 30a1587c24ae698304b5c709f98b612cfda89dab..2742cc266437ddd906ada979b8850e153be68747 100755 (executable)
@@ -42,7 +42,7 @@ int genputtable(struct genhashtable *ht, void * key, void * object) {
     for(i=0;i<oldcurrentsize;i++) {
       struct genpointerlist * tmpptr=oldbins[i];
       while(tmpptr!=NULL) {
-        int hashcode=genhashfunction(ht, tmpptr->src);
+        unsigned int hashcode=genhashfunction(ht, tmpptr->src);
         struct genpointerlist *nextptr=tmpptr->next;
         tmpptr->next=newbins[hashcode];
         newbins[hashcode]=tmpptr;
@@ -60,7 +60,6 @@ int hashsize(struct genhashtable *ht) {
 }
 
 void genrehash(struct genhashtable * ht) {
-  /* Expand hashtable */
   struct genpointerlist **newbins=(struct genpointerlist **) RUNMALLOC(sizeof (struct genpointerlist *)*ht->currentsize);
   struct genpointerlist **oldbins=ht->bins;
   long j,i;
@@ -68,7 +67,7 @@ void genrehash(struct genhashtable * ht) {
   for(i=0;i<ht->currentsize;i++) {
     struct genpointerlist * tmpptr=oldbins[i];
     while(tmpptr!=NULL) {
-      int hashcode=genhashfunction(ht, tmpptr->src);
+      unsigned int hashcode=genhashfunction(ht, tmpptr->src);
       struct genpointerlist *nextptr=tmpptr->next;
       tmpptr->next=newbins[hashcode];
       newbins[hashcode]=tmpptr;
index d7556a721545274d9d4269165dc0b4269abc3054..f77a551d090f63f8c9af9aa95a20633eb6019966 100644 (file)
@@ -228,7 +228,7 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru
        }
        if (hasflags[type]) {
          (((void **)cpy)[2])=flagptr;
-         flagorand(cpy, 1, 0xFFFFFFFF);
+         flagorandinit(cpy, 0, 0xFFFFFFFF);
        }
       }
     }
index 7a7de4651e0a0a47c67a27cd4251fe6cd417a054..b905affb9ec58912620b5254432a7f5df4de474f 100644 (file)
@@ -56,7 +56,7 @@ int main(int argc, char **argv) {
   initializemmap();
 #endif
   processOptions();
-
+  initializeexithandler();
   /* Create table for failed tasks */
   failedtasks=genallocatehashtable((unsigned int (*)(void *)) &hashCodetpd, 
                                   (int (*)(void *,void *)) &comparetpd);
@@ -309,6 +309,7 @@ void executetasks() {
          if (FD_ISSET(fd, &tmpreadfds)) {
            /* Set ready flag on object */
            void * objptr;
+           //      printf("Setting fd %d\n",fd);
            if (RuntimeHashget(fdtoobject, fd,(int *) &objptr)) {
              flagorand(objptr,1,0xFFFFFFFF); /* Set the first flag to 1 */
            }
@@ -425,6 +426,19 @@ void processtasks() {
 
 #endif
 
+void exithandler(int sig, siginfo_t *info, void * uap) {
+  exit(0);
+}
+
+void initializeexithandler() {
+  struct sigaction sig;
+  sig.sa_sigaction=&exithandler;
+  sig.sa_flags=SA_SIGINFO;
+  sigemptyset(&sig.sa_mask);
+  sigaction(SIGUSR2, &sig, 0);
+}
+
+
 /* This function inject failures */
 
 void injectinstructionfailure() {
index 3141f83cb674e9128db83320f8553e49f0e71b50..60b656aa7ac9625c0536f461a8f3bac120d75243 100644 (file)
@@ -16,6 +16,7 @@ struct ArrayObject * allocate_newarray(int type, int length);
 struct ___String___ * NewString(const char *str,int length);
 #endif
 
+void initializeexithandler();
 void failedboundschk();
 void failednullptr();
 void abort_task();
index 542f2deed8c455f7ac96c27fddca3d23e7fafe88..d1ddf28a965db06bae178abdbacd13b997369470 100644 (file)
@@ -292,6 +292,7 @@ void CALL02(___Socket______nativeWrite_____AR_B, struct ___Socket___ * ___this__
 
     if (bytewritten!=length) {
       perror("ERROR IN NATIVEWRITE");
+      printf("Supposed to write %d, wrote %d\n", length, bytewritten);
     }
     break;
   }
@@ -308,13 +309,20 @@ int CALL02(___Socket______nativeRead_____AR_B, struct ___Socket___ * ___this___,
   struct listitem *tmp=stopforgc((struct garbagelist *)___params___);
 #endif
 #endif
-  int byteread=read(fd, charstr, length);
+  int byteread;
+
+  //  printf("Doing read on %d\n",fd);
+  while(1) {
+    byteread=read(fd, charstr, length);
+    
+    break;
+  }
 #ifdef THREADS
 #ifdef PRECISE_GC
   restartaftergc(tmp);
 #endif
 #endif
-
+  
   {
     int i;
     for(i=0;i<byteread;i++) {
@@ -326,7 +334,8 @@ int CALL02(___Socket______nativeRead_____AR_B, struct ___Socket___ * ___this___,
 
   if (byteread<0) {
     printf("ERROR IN NATIVEREAD\n");
-    return 0;
+    perror("");
+    byteread=0;
   }
 #ifdef TASK
   flagorand(VAR(___this___),0,0xFFFFFFFE);
index 5f34adf6187ce58c6257542deb0143cd5a75e4e8..a8b19c02c4cb579073435fd7855de19cb7d2da28 100644 (file)
@@ -54,6 +54,7 @@ void initializethreads() {
   pthread_cond_init(&objcond,NULL);
   pthread_key_create(&threadlocks, NULL);
   processOptions();
+  initializeexithandler();
 
   sig.sa_sigaction=&threadhandler;
   sig.sa_flags=SA_SIGINFO;