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;i<numoids;i++) {
+ unsigned int oid=*((unsigned int *)oidverread);
+ struct readerlist * rl=chashSearch(aborttable, oid);
+ struct readerlist *first=rl;
+ oidverread+=(sizeof(unsigned int)+sizeof(unsigned short));
+ while(1) {
+ for(j=0;j<READERSIZE;j++) {
+ if (rl->array[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;i<size;i++) {
+ chashlistnode_t *curr=&ptr[i];
+ do {
+ unsigned int oid=curr->key;
+ if (oid==0)
+ break;
+ struct readerlist * rl=chashSearch(aborttable, oid);
+ struct readerlist *first=rl;
+ while(1) {
+ for(j=0;j<READERSIZE;j++) {
+ if (rl->array[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<numoids;i++) {
void initreaderlist();
void addtransaction(unsigned int oid, struct transrecord * trans);
void removetransaction(unsigned int oidarray[], unsigned int numoids);
-void removeaborttransaction(unsigned int oidarray[], unsigned int numoids, struct transrecord * trans);
-
+void removethistransaction(unsigned int oidarray[], unsigned int numoids, struct transrecord * trans);
+void removethisreadtransaction(unsigned char* oidverread, unsigned int numoids, struct transrecord * trans);
+void removetransactionhash(chashtable_t *table, struct transrecord *trans);
#endif
#include <netinet/tcp.h>
#include "addUdpEnhance.h"
#include "prelookup.h"
+#ifdef ABORTREADERS
+#include "abortreaders.h"
+#endif
/************************
* Global Variables *
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));
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
}
/* 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__);
}
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;
}
free(listmid);
return 1;
}
+
+
/* Invalidate objects in other machine cache */
if(tosend[i].f.nummod > 0) {
if((retval = invalidateObj(&(tosend[i]))) != 0) {
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
}
}
}
void transAbort(transrecord_t *trans) {
+#ifdef ABORTREADERS
+ removetransactionhash(trans->lookupTable, trans);
+#endif
objstrDelete(trans->cache);
chashDelete(trans->lookupTable);
free(trans);
echo -help help
}
+ABORTREADERS=false;
ROBUSTROOT=~/research/Robust/src
DSMRUNTIME=$ROBUSTROOT/Runtime/DSTM/interface/
REPAIRROOT=~/research/Repair/RepairCompiler/
EXITAFTERANALYSIS=true
elif [[ $1 = '-abortreaders' ]]
then
+ABORTREADERS=true
EXTRAOPTIONS="$EXTRAOPTIONS -DABORTREADERS"
JAVAOPTS="$JAVAOPTS -abortreaders"
elif [[ $1 = '-robustroot' ]]
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"