From ebe6a36c35c3b38db4a88399707834678bc5f487 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 6 Feb 2009 08:49:48 +0000 Subject: [PATCH] abortreaders option finished --- .../src/Runtime/DSTM/interface/abortreaders.c | 82 ++++++++++++++++++- .../src/Runtime/DSTM/interface/abortreaders.h | 5 +- .../Runtime/DSTM/interface/addUdpEnhance.c | 6 ++ Robust/src/Runtime/DSTM/interface/dstm.h | 2 +- Robust/src/Runtime/DSTM/interface/trans.c | 32 +++++++- Robust/src/buildscript | 7 ++ 6 files changed, 126 insertions(+), 8 deletions(-) diff --git a/Robust/src/Runtime/DSTM/interface/abortreaders.c b/Robust/src/Runtime/DSTM/interface/abortreaders.c index a71aae2d..73e9033a 100644 --- a/Robust/src/Runtime/DSTM/interface/abortreaders.c +++ b/Robust/src/Runtime/DSTM/interface/abortreaders.c @@ -73,7 +73,87 @@ void removetransaction(unsigned int oidarray[], unsigned int numoids) { pthread_mutex_unlock(&aborttablelock); } -void removeaborttransaction(unsigned int oidarray[], unsigned int numoids, struct transrecord * trans) { +void removethisreadtransaction(unsigned char* oidverread, unsigned int numoids, struct transrecord * trans) { + int i,j; + pthread_mutex_lock(&aborttablelock); + for(i=0;iarray[j]==trans) { + rl->array[j]=NULL; + if ((--rl->numreaders)==0) { + if (first==rl) { + chashRemove2(table, oid); + if (rl->next!=NULL) + chashInsert(table, oid, rl->next); + rl->next=freelist; + freelist=rl; + } else { + first->next=rl->next; + rl->next=freelist; + freelist=rl; + } + } + goto nextitem; + } + } + first=rl; + rl=rl->next; + } + nextitem: + } + pthread_mutex_unlock(&aborttablelock); +} + +void removetransactionhash(chashtable_t *table, struct transrecord *trans) { + chashlistnode_t *ptr=table->table; + unsigned int size=table->size; + int i,j; + pthread_mutex_lock(&aborttablelock); + for(i=0;ikey; + if (oid==0) + break; + struct readerlist * rl=chashSearch(aborttable, oid); + struct readerlist *first=rl; + while(1) { + for(j=0;jarray[j]==trans) { + rl->array[j]=NULL; + if ((--rl->numreaders)==0) { + if (first==rl) { + chashRemove2(table, oid); + if (rl->next!=NULL) + chashInsert(table, oid, rl->next); + rl->next=freelist; + freelist=rl; + } else { + first->next=rl->next; + rl->next=freelist; + freelist=rl; + } + } + goto nextitem; + } + } + first=rl; + rl=rl->next; + } + nextitem: + curr=curr->next; + } while(curr!=NULL); + } + pthread_mutex_unlock(&aborttablelock); +} + + +void removethistransaction(unsigned int oidarray[], unsigned int numoids, struct transrecord * trans) { int i,j; pthread_mutex_lock(&aborttablelock); for(i=0;i #include "addUdpEnhance.h" #include "prelookup.h" +#ifdef ABORTREADERS +#include "abortreaders.h" +#endif /************************ * Global Variables * @@ -197,6 +200,9 @@ int invalidateFromPrefetchCache(char *buffer) { int numObjsRecv = *((short *)(buffer+offset)) / sizeof(unsigned int); offset += sizeof(short); int i; +#ifdef ABORTREADERS + removetransaction((unsigned int *)(buffer+offset), numObjsRecv); +#endif for(i = 0; i < numObjsRecv; i++) { unsigned int oid; oid = *((unsigned int *)(buffer+offset)); diff --git a/Robust/src/Runtime/DSTM/interface/dstm.h b/Robust/src/Runtime/DSTM/interface/dstm.h index d501be66..356e4490 100644 --- a/Robust/src/Runtime/DSTM/interface/dstm.h +++ b/Robust/src/Runtime/DSTM/interface/dstm.h @@ -282,7 +282,7 @@ void addHost(unsigned int); void mapObjMethod(unsigned short); void randomdelay(); -transrecord_t *transStart(); +__attribute__((malloc)) transrecord_t *transStart(); __attribute__((pure)) objheader_t *transRead(transrecord_t *, unsigned int); objheader_t *transCreateObj(transrecord_t *, unsigned int); //returns oid header int transCommit(transrecord_t *record); //return 0 if successful diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index 0b64b923..85564b8b 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -320,7 +320,7 @@ void randomdelay() { } /* This function initializes things required in the transaction start*/ -transrecord_t *transStart() { +__attribute__((malloc)) transrecord_t *transStart() { transrecord_t *tmp; if((tmp = calloc(1, sizeof(transrecord_t))) == NULL) { printf("%s() Calloc error at line %d, %s\n", __func__, __LINE__, __FILE__); @@ -328,9 +328,9 @@ transrecord_t *transStart() { } tmp->cache = objstrCreate(1048576); tmp->lookupTable = chashCreate(CHASH_SIZE, CLOADFACTOR); -#ifdef COMPILER - tmp->revertlist=NULL; -#endif + //#ifdef COMPILER + // tmp->revertlist=NULL; //Not necessary...already null + //#endif return tmp; } @@ -741,6 +741,8 @@ int transCommit(transrecord_t *record) { free(listmid); return 1; } + + /* Invalidate objects in other machine cache */ if(tosend[i].f.nummod > 0) { if((retval = invalidateObj(&(tosend[i]))) != 0) { @@ -750,12 +752,31 @@ int transCommit(transrecord_t *record) { return 1; } } +#ifdef ABORTREADERS + removetransaction(tosend[i].oidmod,tosend[i].f.nummod); + removethisreadtransaction(tosend[i].oidmod,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); } +#endif #endif send_data(sd, &finalResponse, sizeof(char)); } else { /* Complete local processing */ doLocalProcess(finalResponse, &(tosend[i]), &transinfo, record); +#ifdef ABORTREADERS + if(finalResponse == TRANS_COMMIT) { + removetransaction(tosend[i].oidmod,tosend[i].f.nummod); + removethisreadtransaction(tosend[i].oidmod,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); + } +#endif } } @@ -1779,6 +1800,9 @@ int notifyAll(threadlist_t **head, unsigned int oid, unsigned int version) { } void transAbort(transrecord_t *trans) { +#ifdef ABORTREADERS + removetransactionhash(trans->lookupTable, trans); +#endif objstrDelete(trans->cache); chashDelete(trans->lookupTable); free(trans); diff --git a/Robust/src/buildscript b/Robust/src/buildscript index bd4928ed..bde78a2b 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -50,6 +50,7 @@ echo -justanalyze exit after compiler analyses complete echo -help help } +ABORTREADERS=false; ROBUSTROOT=~/research/Robust/src DSMRUNTIME=$ROBUSTROOT/Runtime/DSTM/interface/ REPAIRROOT=~/research/Repair/RepairCompiler/ @@ -98,6 +99,7 @@ then EXITAFTERANALYSIS=true elif [[ $1 = '-abortreaders' ]] then +ABORTREADERS=true EXTRAOPTIONS="$EXTRAOPTIONS -DABORTREADERS" JAVAOPTS="$JAVAOPTS -abortreaders" elif [[ $1 = '-robustroot' ]] @@ -426,6 +428,11 @@ fi FILES="$FILES $DSMRUNTIME/trans.c $DSMRUNTIME/mcpileq.c $DSMRUNTIME/objstr.c $DSMRUNTIME/dstm.c $DSMRUNTIME/mlookup.c $DSMRUNTIME/clookup.c $DSMRUNTIME/llookup.c $DSMRUNTIME/threadnotify.c $DSMRUNTIME/dstmserver.c $DSMRUNTIME/plookup.c $DSMRUNTIME/ip.c $DSMRUNTIME/queue.c $DSMRUNTIME/prelookup.c $DSMRUNTIME/machinepile.c $ROBUSTROOT/Runtime/localobjects.c $ROBUSTROOT/Runtime/thread.c $DSMRUNTIME/sockpool.c $DSMRUNTIME/addUdpEnhance.c $DSMRUNTIME/signal.c $DSMRUNTIME/gCollect.c $DSMRUNTIME/addPrefetchEnhance.c $DSMRUNTIME/dsmlock.c $DSMRUNTIME/prefetch.c" fi +if $ABORTREADERS +then +FILES="$FILES $DSMRUNTIME/abortreaders.c" +fi + if $FASTCHECK then FILES="$FILES $ROBUSTROOT/Runtime/localobjects.c" -- 2.34.1