From: adash Date: Thu, 14 Feb 2008 22:43:19 +0000 (+0000) Subject: bug fixes X-Git-Tag: preEdgeChange~277 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ff5a79fd5b7d2cb21b7dcf1fa60ee6f6990f50ab;p=IRC.git bug fixes Thread join works; No SegFaults ; All code in working condition --- diff --git a/Robust/src/Runtime/DSTM/interface/threadnotify.c b/Robust/src/Runtime/DSTM/interface/threadnotify.c index 3d7f2928..a04f3135 100644 --- a/Robust/src/Runtime/DSTM/interface/threadnotify.c +++ b/Robust/src/Runtime/DSTM/interface/threadnotify.c @@ -257,5 +257,6 @@ unsigned int notifyhashResize(unsigned int newsize) { } free(ptr); //Free the memory of the old hash table + ptr = NULL; return 0; } diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index 2aa4551e..47d8d6ea 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -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); diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index d5f195e8..be69af35 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -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]; diff --git a/Robust/src/Tests/Atomic5.java b/Robust/src/Tests/Atomic5.java index c4659e07..34274447 100644 --- a/Robust/src/Tests/Atomic5.java +++ b/Robust/src/Tests/Atomic5.java @@ -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]; }