bug fixes
authoradash <adash>
Thu, 14 Feb 2008 22:43:19 +0000 (22:43 +0000)
committeradash <adash>
Thu, 14 Feb 2008 22:43:19 +0000 (22:43 +0000)
Thread join works; No SegFaults ; All code in working condition

Robust/src/Runtime/DSTM/interface/threadnotify.c
Robust/src/Runtime/DSTM/interface/trans.c
Robust/src/Runtime/thread.c
Robust/src/Tests/Atomic5.java

index 3d7f2928176e94005923653c8ba432a3a638ebff..a04f3135cd24578025ae35dfc65ddcf6ff7be4bb 100644 (file)
@@ -257,5 +257,6 @@ unsigned int notifyhashResize(unsigned int newsize) {
        }
 
        free(ptr);              //Free the memory of the old hash table 
+       ptr = NULL;
        return 0;
 }
index 2aa4551e8fa2f33f68df75788bb188cfc6d154de..47d8d6ea089447e22d314ac9866368d35f5a6818 100644 (file)
@@ -119,31 +119,25 @@ void prefetch(int ntuples, unsigned int *oids, unsigned short *endoffsets, short
 
 /* This function starts up the transaction runtime. */
 int dstmStartup(const char * option) {
-  pthread_t thread_Listen;
-  pthread_attr_t attr;
-  int master=option!=NULL && strcmp(option, "master")==0;
+       pthread_t thread_Listen;
+       pthread_attr_t attr;
+       int master=option!=NULL && strcmp(option, "master")==0;
 
        if (processConfigFile() != 0)
                return 0; //TODO: return error value, cause main program to exit
 
-       //TODO Remove after testing
-       //Initializing the global array
-       int i;
-       for (i = 0; i < 10000; i++) 
-               mlist[i] = NULL;
-       ////////
-  dstmInit();
-  transInit();
-
-  if (master) {
-    pthread_attr_init(&attr);
-    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-    pthread_create(&thread_Listen, &attr, dstmListen, NULL);
-    return 1;
-  } else {
-    dstmListen();
-    return 0;
-  }
+       dstmInit();
+       transInit();
+
+       if (master) {
+               pthread_attr_init(&attr);
+               pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+               pthread_create(&thread_Listen, &attr, dstmListen, NULL);
+               return 1;
+       } else {
+               dstmListen();
+               return 0;
+       }
 
 }
 
@@ -244,20 +238,6 @@ transrecord_t *transStart()
        transrecord_t *tmp = calloc(1, sizeof(transrecord_t));
        tmp->cache = objstrCreate(1048576);
        tmp->lookupTable = chashCreate(HASH_SIZE, LOADFACTOR);
-       //TODO Remove after testing
-       //Filling the global array when transansaction's record lookupTable
-       //is calloced 
-       pthread_mutex_lock(&mlock);
-       int ii;
-       for (ii = 0; ii < 10000; ii++) {
-               if (mlist[ii] == NULL) {
-                       mlist[ii] = (void *)tmp->lookupTable; 
-                       break;
-               }
-       }
-       if (ii == 10000) { fprintf(stderr, "Error"); }
-       pthread_mutex_unlock(&mlock);
-       ////////////
 #ifdef COMPILER
        tmp->revertlist=NULL;
 #endif
@@ -610,22 +590,6 @@ int transCommit(transrecord_t *record) {
        if(treplyctrl == TRANS_ABORT) {
                /* Free Resources */
                objstrDelete(record->cache);
-               //TODO Remove after testing 
-               pthread_mutex_lock(&mlock);
-               int count = 0, jj = 0, ii = 0;
-               for (ii = 0; ii < 10000; ii++) {
-                       if (mlist[ii] == (void *) record->lookupTable) {
-                               count++; 
-                               jj = ii;
-                       }
-               }
-               if (count==2 || count == 0) { 
-                       fprintf(stderr, "TRANS_ABORT CASE: Count for same addr:%d\n", count); 
-               }
-               if (count == 1) 
-                       mlist[jj] = 0;
-               pthread_mutex_unlock(&mlock);
-               ////////////
                chashDelete(record->lookupTable);
                free(record);
                free(thread_data_array);
@@ -634,18 +598,6 @@ int transCommit(transrecord_t *record) {
        } else if(treplyctrl == TRANS_COMMIT) {
                /* Free Resources */
                objstrDelete(record->cache);
-               //TODO Remove after Testing
-               pthread_mutex_lock(&mlock);
-               int count = 0, jj = 0, ii = 0;
-               for (ii = 0; ii < 10000; ii++) {
-                       if (mlist[ii] == (void *) record->lookupTable) {count++; jj = ii;}
-               }
-               if (count==2 || count == 0) { 
-                       fprintf(stderr, "TRANS_COMMIT CASE: Count for same addr:%d\n", count); 
-               }
-               if (count == 1) mlist[jj] = 0;
-               pthread_mutex_unlock(&mlock);
-               ///////////////////////
                chashDelete(record->lookupTable);
                free(record);
                free(thread_data_array);
index d5f195e8604fc396d3d4c5c4e2badcdc454e15d4..be69af3537497b571f20428de248176f1296b8c8 100644 (file)
@@ -19,12 +19,12 @@ pthread_cond_t objcond;
 pthread_key_t threadlocks;
 pthread_mutex_t threadnotifylock;
 pthread_cond_t threadnotifycond;
-transrecord_t * trans;
 pthread_key_t oidval;
 
 void threadexit() {
   objheader_t* ptr;
   void *value;
+  transrecord_t * trans;
   unsigned int oidvalue;
 
 #ifdef THREADS
@@ -126,7 +126,6 @@ void CALL11(___Thread______sleep____J, long long ___millis___, long long ___mill
 #ifdef DSTM
 /* Add thread join capability */
 void CALL01(___Thread______join____, struct ___Thread___ * ___this___) {
-  pthread_t thread;
   unsigned int *oidarray;
   unsigned short *versionarray, version;
   transrecord_t *trans;
@@ -201,6 +200,7 @@ void globalDestructor(void *value) {
 
 void initDSMthread(int *ptr) {
   objheader_t *tmp;    
+  transrecord_t * trans;
   void *threadData;
   int oid=ptr[0];
   int type=ptr[1];
index c4659e0741b62349b489c8b6ce4142f9c1799b97..342744473e80ce0dc565e71e45c31e4ac658c24f 100644 (file)
@@ -6,6 +6,7 @@ public class Atomic5 extends Thread {
        public static void main(String[] st) {
                int mid = (128<<24)|(195<<16)|(175<<8)|70;
                int b = 0,c = 0;
+               int i;
                
                Integer age;
                Atomic5 tmp;
@@ -15,7 +16,7 @@ public class Atomic5 extends Thread {
                        at5 =  global new Atomic5[4];
                }
                atomic {
-                       for(int i = 0; i < 4; i++) {
+                       for(i = 0; i < 4; i++) {
                                at5[i] = global new Atomic5();
                                at5[i].team = global new People[2];
                                at5[i].team[0] = global new People();
@@ -37,13 +38,13 @@ public class Atomic5 extends Thread {
                System.printInt(c);
                System.printString("\n");
                System.printString("Starting\n");
-               for(int i = 0 ; i< 4; i++) {
+               for(i = 0 ; i< 4; i++) {
                        atomic {
                                tmp = at5[i];
                        }
                        tmp.start(mid);
                }
-               for(int i = 0; i< 4; i++) {
+               for(i = 0; i< 4; i++) {
                        atomic {
                                tmp = at5[i];
                        }