}
if (state.THREAD||state.DSM||state.SINGLETM) {
outmethod.println("initializethreads();");
+ outmethod.println("#ifdef STMSTATS \n");
+ outmethod.println(" for(i=0; i<TOTALNUMCLASSANDARRAY; i++) {\n");
+ outmethod.println(" typesCausingAbort[i] = 0;\n");
+ outmethod.println(" }\n");
+ outmethod.println("#endif\n");
}
if (state.DSM) {
outmethod.println("if (dstmStartup(argv[1])) {");
} else if (state.SINGLETM) {
outmethod.println("printf(\"nSoftAbortAbort= %d\\n\", nSoftAbortAbort);");
outmethod.println("printf(\"nSoftAbortCommit= %d\\n\", nSoftAbortCommit);");
+ outmethod.println("for(i=0; i<TOTALNUMCLASSANDARRAY; i++) {\n");
+ outmethod.println(" printf(\"typesCausingAbort[%d]= %d\\n\", i, typesCausingAbort[i]);\n");
+ outmethod.println("}\n");
+ outmethod.println("fflush(stdout);");
}
outmethod.println("#endif\n");
}
(state.getArrayNumber((new TypeDescriptor(TypeDescriptor.BYTE)).makeArray(state).makeArray(state))+state.numClasses()));
outstructs.println("#define NUMCLASSES "+state.numClasses());
+ int totalClassSize = state.numClasses() + state.numArrays();
+ outstructs.println("#define TOTALNUMCLASSANDARRAY "+ totalClassSize);
if (state.TASK) {
outstructs.println("#define STARTUPTYPE "+typeutil.getClass(TypeUtil.StartupClass).getId());
outstructs.println("#define TAGTYPE "+typeutil.getClass(TypeUtil.TagClass).getId());
} else if (state.SINGLETM) {
outclassdefs.println("extern int nSoftAbortAbort;");
outclassdefs.println("extern int nSoftAbortCommit;");
+ outclassdefs.println("extern int typesCausingAbort[];");
}
outclassdefs.print("#endif\n");
outclassdefs.print("int numprefetchsites = " + pa.prefetchsiteid + ";\n");
outclassdefs.print("sizeof(struct "+cdarray[i].getSafeSymbol()+")");
needcomma=true;
}
+
arraytable=new TypeDescriptor[state.numArrays()];
int nSoftAbort = 0;
int nSoftAbortCommit = 0;
int nSoftAbortAbort = 0;
+int typesCausingAbort[TOTALNUMCLASSANDARRAY];
+#endif
+
+#ifdef STMSTATS
+/******Keep track of objects and types causing aborts******/
+#define DEBUGSTMSTAT(args...) { \
+ printf(args); \
+ fflush(stdout); \
+}
+#else
+#define DEBUGSTMSTAT(args...)
#endif
#ifdef STMDEBUG
size += sizeof(objheader_t);
objcopy = (objheader_t *) objstrAlloc(size);
memcpy(objcopy, header, size);
+#ifdef STMSTATS
+ header->accessCount++;
+#endif
/* Insert into cache's lookup table */
STATUS(objcopy)=0;
t_chashInsert(oid, &objcopy[1]);
} else {
oidwrlocked[numoidwrlocked++] = OID(header);
transAbortProcess(oidwrlocked, numoidwrlocked);
+#ifdef STMSTATS
+ header->abortCount++;
+ (typesCausingAbort[TYPE(header)])++;
+#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);
if (c_numelements>=200) {
free(oidrdlocked);
free(oidrdversion);
return TRANS_ABORT;
}
} else { /* cannot aquire lock */
+#ifdef STMSTATS
+ header->abortCount++;
+ (typesCausingAbort[TYPE(header)])++;
+#endif
if(version == header->version) {
/* versions match */
softabort=1;
} else {
transAbortProcess(oidwrlocked, numoidwrlocked);
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);
if (c_numelements>=200) {
free(oidrdlocked);
free(oidrdversion);
if(version != header->version) {/* versions do not match */
oidrdlocked[numoidrdlocked++] = OID(header);
transAbortProcess(oidwrlocked, numoidwrlocked);
+#ifdef STMSTATS
+ header->abortCount++;
+ (typesCausingAbort[TYPE(header)])++;
+#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);
if (c_numelements>=200) {
free(oidrdlocked);
free(oidrdversion);
return TRANS_ABORT;
}
} else { /* cannot aquire lock */
+#ifdef STMSTATS
+ header->abortCount++;
+ (typesCausingAbort[TYPE(header)])++;
+#endif
//do increment as we didn't get lock
if(version == header->version) {
softabort=1;
} else {
transAbortProcess(oidwrlocked, numoidwrlocked);
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);
if (c_numelements>=200) {
free(oidrdlocked);
free(oidrdversion);
}
/* ==================================================
- * traverseCache
+ * alttraverseCache
* - goes through the transaction cache and
* - decides if a transaction should commit or abort
* ==================================================
} else {
oidwrlocked[numoidwrlocked++] = OID(header);
transAbortProcess(oidwrlocked, numoidwrlocked);
+#ifdef STMSTATS
+ header->abortCount++;
+ (typesCausingAbort[TYPE(header)])++;
+#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);
if (c_numelements>=200) {
free(oidrdlocked);
free(oidrdversion);
softabort=1;
} else {
transAbortProcess(oidwrlocked, numoidwrlocked);
+#ifdef STMSTATS
+ header->abortCount++;
+ (typesCausingAbort[TYPE(header)])++;
+#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);
if (c_numelements>=200) {
free(oidrdlocked);
free(oidrdversion);
if(header->lock>=0) {
if(version != header->version) {
transAbortProcess(oidwrlocked, numoidwrlocked);
+#ifdef STMSTATS
+ header->abortCount++;
+ (typesCausingAbort[TYPE(header)])++;
+#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);
if (c_numelements>=200) {
free(oidrdlocked);
free(oidrdversion);
return TRANS_ABORT;
}
} else { /* cannot aquire lock */
+#ifdef STMSTATS
+ header->abortCount++;
+ (typesCausingAbort[TYPE(header)])++;
+#endif
if(version == header->version) {
softabort=1;
} else {
transAbortProcess(oidwrlocked, numoidwrlocked);
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);
if (c_numelements>=200) {
free(oidrdlocked);
free(oidrdversion);