From 740230740bb59c610b16546a4be489cb23f1f4c7 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 6 Feb 2009 10:10:21 +0000 Subject: [PATCH] abort bug fixes --- .../src/Runtime/DSTM/interface/abortreaders.c | 31 +++++++++++-------- Robust/src/Runtime/DSTM/interface/dstm.h | 3 ++ Robust/src/Runtime/DSTM/interface/trans.c | 18 +++++++---- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/Robust/src/Runtime/DSTM/interface/abortreaders.c b/Robust/src/Runtime/DSTM/interface/abortreaders.c index 73e9033a..860655b5 100644 --- a/Robust/src/Runtime/DSTM/interface/abortreaders.c +++ b/Robust/src/Runtime/DSTM/interface/abortreaders.c @@ -25,7 +25,7 @@ void addtransaction(unsigned int oid, struct transrecord * trans) { freelist=rl->next; memset(rl,0, sizeof(struct readerlist)); } - chashInsert(rl, oid, rl); + chashInsert(aborttable, oid, rl); } while(rl->numreaders==READERSIZE) { if (rl->next!=NULL) @@ -52,11 +52,14 @@ void removetransaction(unsigned int oidarray[], unsigned int numoids) { pthread_mutex_lock(&aborttablelock); for(i=0;inumreaders; - for(int j=0;count;j++) { + int count=rl->numreaders; + int j; + for(j=0;count;j++) { struct transrecord *trans=rl->array[j]; if (trans!=NULL) { trans->abort=1;//It's okay to set our own abort flag...it is @@ -81,15 +84,15 @@ void removethisreadtransaction(unsigned char* oidverread, unsigned int numoids, struct readerlist * rl=chashSearch(aborttable, oid); struct readerlist *first=rl; oidverread+=(sizeof(unsigned int)+sizeof(unsigned short)); - while(1) { + while(rl!=NULL) { for(j=0;jarray[j]==trans) { rl->array[j]=NULL; if ((--rl->numreaders)==0) { if (first==rl) { - chashRemove2(table, oid); + chashRemove2(aborttable, oid); if (rl->next!=NULL) - chashInsert(table, oid, rl->next); + chashInsert(aborttable, oid, rl->next); rl->next=freelist; freelist=rl; } else { @@ -105,6 +108,7 @@ void removethisreadtransaction(unsigned char* oidverread, unsigned int numoids, rl=rl->next; } nextitem: + ; } pthread_mutex_unlock(&aborttablelock); } @@ -122,15 +126,15 @@ void removetransactionhash(chashtable_t *table, struct transrecord *trans) { break; struct readerlist * rl=chashSearch(aborttable, oid); struct readerlist *first=rl; - while(1) { + while(rl!=NULL) { for(j=0;jarray[j]==trans) { rl->array[j]=NULL; if ((--rl->numreaders)==0) { if (first==rl) { - chashRemove2(table, oid); + chashRemove2(aborttable, oid); if (rl->next!=NULL) - chashInsert(table, oid, rl->next); + chashInsert(aborttable, oid, rl->next); rl->next=freelist; freelist=rl; } else { @@ -161,15 +165,15 @@ void removethistransaction(unsigned int oidarray[], unsigned int numoids, struct struct readerlist * rl=chashSearch(aborttable, oid); struct readerlist *first=rl; - while(1) { + while(rl!=NULL) { for(j=0;jarray[j]==trans) { rl->array[j]=NULL; if ((--rl->numreaders)==0) { if (first==rl) { - chashRemove2(table, oid); + chashRemove2(aborttable, oid); if (rl->next!=NULL) - chashInsert(table, oid, rl->next); + chashInsert(aborttable, oid, rl->next); rl->next=freelist; freelist=rl; } else { @@ -185,6 +189,7 @@ void removethistransaction(unsigned int oidarray[], unsigned int numoids, struct rl=rl->next; } nextitem: + ; } pthread_mutex_unlock(&aborttablelock); } diff --git a/Robust/src/Runtime/DSTM/interface/dstm.h b/Robust/src/Runtime/DSTM/interface/dstm.h index 356e4490..8a458dc5 100644 --- a/Robust/src/Runtime/DSTM/interface/dstm.h +++ b/Robust/src/Runtime/DSTM/interface/dstm.h @@ -83,6 +83,9 @@ #include #include "plookup.h" #include "dsmdebug.h" +#ifdef ABORTREADERS +#include +#endif //bit designations for status field of objheader #define DIRTY 0x01 diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index 85564b8b..5c1249fa 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -15,6 +15,9 @@ #ifdef COMPILER #include "thread.h" #endif +#ifdef ABORTREADERS +#include "abortreaders.h" +#endif #define NUM_THREADS 1 #define PREFETCH_CACHE_SIZE 1048576 //1MB @@ -194,6 +197,9 @@ int dstmStartup(const char * option) { printf("Trans stats is on\n"); fflush(stdout); #endif +#ifdef ABORTREADERS + initreaderlist(); +#endif //Initialize socket pool transReadSockPool = createSockPool(transReadSockPool, DEFAULTSOCKPOOLSIZE); @@ -397,9 +403,9 @@ __attribute__((pure)) objheader_t *transRead(transrecord_t *record, unsigned int */ #ifdef ABORTREADERS - if (trans->abort) { + if (record->abort) { //abort this transaction - longjmp(trans->aborttrans,1); + longjmp(record->aborttrans,1); } else addtransaction(oid,record); #endif @@ -754,13 +760,13 @@ int transCommit(transrecord_t *record) { } #ifdef ABORTREADERS removetransaction(tosend[i].oidmod,tosend[i].f.nummod); - removethisreadtransaction(tosend[i].oidmod,tosend[i].f.numread, record); + removethisreadtransaction(tosend[i].objread, tosend[i].f.numread, record); #endif } #ifdef ABORTREADERS else if (!treplyretry) { removethistransaction(tosend[i].oidmod,tosend[i].f.nummod,record); - removethisreadtransaction(tosend[i].oidmod,tosend[i].f.numread,record); + removethisreadtransaction(tosend[i].objread,tosend[i].f.numread,record); } #endif #endif @@ -771,10 +777,10 @@ int transCommit(transrecord_t *record) { #ifdef ABORTREADERS if(finalResponse == TRANS_COMMIT) { removetransaction(tosend[i].oidmod,tosend[i].f.nummod); - removethisreadtransaction(tosend[i].oidmod,tosend[i].f.numread, record); + removethisreadtransaction(tosend[i].objread,tosend[i].f.numread, record); } else if (!treplyretry) { removethistransaction(tosend[i].oidmod,tosend[i].f.nummod,record); - removethisreadtransaction(tosend[i].oidmod,tosend[i].f.numread,record); + removethisreadtransaction(tosend[i].objread,tosend[i].f.numread,record); } #endif } -- 2.34.1