#include "tm.h"
#include "garbage.h"
-
+#define likely(x) x
/* Per thread transaction variables */
__thread objstr_t *t_cache;
__thread objstr_t *t_reserve;
nSoftAbort++;
#endif
softaborted++;
+#ifdef SOFTABORT
+ if (softaborted>1) {
+#else
if (1) {
- //if (softaborted>1) {
+#endif
//retry if too many soft aborts
freenewobjs();
#ifdef STMSTATS
free(oidrdversion);
free(oidwrlocked);
}
+ if (softabort)
+ return TRANS_SOFT_ABORT;
+ else
return TRANS_ABORT;
}
} else { /* cannot aquire lock */
#ifdef STMSTATS
ABORTCOUNT(header);
(typesCausingAbort[TYPE(header)])++;
- getTotalAbortCount(i+1, size, (void *)(curr->next), NULL, 1);
+#endif
+#if defined(STMSTATS)||defined(SOFTABORT)
+ if (getTotalAbortCount(i+1, size, (void *)(curr->next), NULL, 1))
+ softabort=0;
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
free(oidrdversion);
free(oidwrlocked);
}
- return TRANS_ABORT;
+ if (softabort)
+ return TRANS_SOFT_ABORT;
+ else
+ return TRANS_ABORT;
}
} else {
oidrdversion[numoidrdlocked]=version;
#ifdef STMSTATS
ABORTCOUNT(header);
(typesCausingAbort[TYPE(header)])++;
- getTotalAbortCount(i+1, numoidrdlocked, oidrdlocked, (void *) oidrdversion, 0);
+#endif
+#if defined(STMSTATS)||defined(SOFTABORT)
+ if (getTotalAbortCount(i+1, numoidrdlocked, oidrdlocked, (void *) oidrdversion, 0))
+ softabort=0;
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
free(oidrdversion);
free(oidwrlocked);
}
- return TRANS_ABORT;
+ if (softabort)
+ return TRANS_SOFT_ABORT;
+ else
+ return TRANS_ABORT;
}
}
#ifdef STMSTATS
ABORTCOUNT(header);
(typesCausingAbort[TYPE(header)])++;
- getTotalAbortCount(0, 1, (void *) curr->next, NULL, 1);
+#endif
+#if defined(STMSTATS)||defined(SOFTABORT)
+ if (getTotalAbortCount(0, 1, (void *) curr->next, NULL, 1))
+ softabort=0;
#endif
DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
free(oidrdversion);
free(oidwrlocked);
}
- return TRANS_ABORT;
+ if (softabort)
+ return TRANS_SOFT_ABORT;
+ else
+ return TRANS_ABORT;
}
} else {
/* Read from the main heap and compare versions */
#ifdef STMSTATS
ABORTCOUNT(header);
(typesCausingAbort[TYPE(header)])++;
- getTotalAbortCount(i+1, numoidrdlocked, oidrdlocked, (void *)oidrdversion, 0);
+#endif
+#if defined(STMSTATS)||defined(SOFTABORT)
+ if (getTotalAbortCount(i+1, numoidrdlocked, oidrdlocked, (void *)oidrdversion, 0))
+ softabort=0;
#endif
DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version);
DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version);
free(oidrdversion);
free(oidwrlocked);
}
- return TRANS_ABORT;
+ if (softabort)
+ return TRANS_SOFT_ABORT;
+ else
+ return TRANS_ABORT;
}
}
*
* =================================
*/
-int transCommitProcess(void ** oidwrlocked, int numoidwrlocked) {
+void transCommitProcess(void ** oidwrlocked, int numoidwrlocked) {
objheader_t *header;
void *ptrcreate;
int i;
ptr=ptr->next;
}
#endif
-
- return 0;
}
/** ========================================================================================
* 0='r'/1='w' if found when visiting objects read/ objects modified
* =========================================================================================
**/
-#ifdef STMSTATS
-void getTotalAbortCount(int start, int stop, void *startptr, void *checkptr, int type) {
+#if defined(STMSTATS)||defined(SOFTABORT)
+int getTotalAbortCount(int start, int stop, void *startptr, void *checkptr, int type) {
int i;
+ int hardabort=0;
if(type) {
int isFirstTime = 0;
chashlistnode_t *curr = (chashlistnode_t *) startptr;
unsigned int version = headeraddr->version;
/* versions do not match */
if(version != header->version) {
+#ifdef STMSTATS
ABORTCOUNT(header);
(typesCausingAbort[TYPE(header)])++;
+#endif
+ hardabort=1;
}
curr = curr->next;
}
objheader_t *header = ((void **)startptr)[i];
unsigned int version = ((int *)checkptr)[i];
if(version != header->version) { /* versions do not match */
+#ifdef STMSTATS
ABORTCOUNT(header);
(typesCausingAbort[TYPE(header)])++;
+#endif
+ hardabort=1;
}
}
}
+ return hardabort;
}
/**