#include "runtime.h"
#include <sys/types.h>
+#include <sys/mman.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include "tm.h"
#endif
#include <execinfo.h>
+#ifdef EVENTMONITOR
+#include "monitor.h"
+#endif
int threadcount;
pthread_cond_t threadnotifycond;
pthread_key_t oidval;
-#if defined(THREADS) || defined(DSTM) || defined(STM)
+#if defined(THREADS) || defined(DSTM) || defined(STM)||defined(MLP)
#ifndef MAC
extern __thread struct listitem litem;
#else
threadexit();
}
-struct primitivelist *pl;
+#define downpage(x) ((void *)(((INTPTR)x)&~((INTPTR)4095)))
void initializethreads() {
struct sigaction sig;
#endif
processOptions();
initializeexithandler();
+#ifdef AFFINITY
+ set_affinity();
+#endif
//deprecated use of sighandler, but apparently still works
#ifdef SANDBOX
sig.sa_handler=(void *)errorhandler;
+ abortenabled=0;
#else
sig.sa_handler=(void *)threadhandler;
#endif
dc_t_chashCreate(CHASH_SIZE, CLOADFACTOR);
ptrstack.count=0;
primstack.count=0;
- pl=&primstack;
+ branchstack.count=0;
+#if defined(STMARRAY)&&!defined(DUALVIEW)
+ arraystack.count=0;
+#endif
+ int a=mprotect((downpage(&ptrstack.buffer[1024])), 4096, PROT_NONE);
+ if (a==-1)
+ perror("ptrstack");
+ a=mprotect(downpage(&primstack.array[MAXVALUES]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("primstack");
+ a=mprotect(downpage(&branchstack.array[MAXBRANCHES]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("branchstack");
+#if defined(STMARRAY)&&!defined(DUALVIEW)
+ a=mprotect(downpage(&arraystack.index[MAXARRAY]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("arraystack");
+#endif
#endif
#ifdef STMSTATS
trec=calloc(1, sizeof(threadrec_t));
{
int i;
for(i=0; i<TOTALNUMCLASSANDARRAY; i++) {
- typesCausingAbort[i] = 0;
+ typesCausingAbort[i].numaccess = 0;
+ typesCausingAbort[i].numabort = 0;
+ typesCausingAbort[i].numtrans = 0;
}
}
#endif
list->prev=&litem;
list=&litem;
#endif
+#ifdef EVENTMONITOR
+ createmonitor();
+#endif
}
#if defined(THREADS)||defined(STM)
void initthread(struct ___Thread___ * ___this___) {
+#ifdef AFFINITY
+ set_affinity();
+#endif
+#ifdef EVENTMONITOR
+ createmonitor();
+#endif
+#ifdef SANDBOX
+ struct sigaction sig;
+ abortenabled=0;
+ sig.sa_handler=(void *)errorhandler;
+ sig.sa_flags=SA_RESTART;
+ sigemptyset(&sig.sa_mask);
+
+ /* Catch bus errors, segmentation faults, and floating point exceptions*/
+ sigaction(SIGBUS,&sig,0);
+ sigaction(SIGSEGV,&sig,0);
+ sigaction(SIGFPE,&sig,0);
+#endif
#ifdef PRECISE_GC
INTPTR p[]={1, (INTPTR) NULL, (INTPTR) ___this___};
//Add our litem to list of threads
dc_t_chashCreate(CHASH_SIZE, CLOADFACTOR);
ptrstack.count=0;
primstack.count=0;
+ branchstack.count=0;
+#if defined(STMARRAY)&&!defined(DUALVIEW)
+ arraystack.count=0;
+#endif
+ int a=mprotect(downpage(&ptrstack.buffer[1024]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("ptrstack");
+ a=mprotect(downpage(&primstack.array[MAXVALUES]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("primstack");
+ a=mprotect(downpage(&branchstack.array[MAXBRANCHES]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("branchstack");
+#if defined(STMARRAY)&!defined(DUALVIEW)
+ a=mprotect(downpage(&arraystack.index[MAXARRAY]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("arraystack");
+#endif
#endif
___Thread____NNR____staticStart____L___Thread___((struct ___Thread____NNR____staticStart____L___Thread____params *)p);
objstrDelete(t_cache);
}
#endif
+#ifdef D___Thread______abort____
+void CALL00(___Thread______abort____) {
+#ifdef SANDBOX
+ _longjmp(aborttrans,1);
+#endif
+}
+#endif
+
#ifdef DSTM
#ifdef RECOVERY
// return if the machine is dead
int retval;
pthread_attr_t nattr;
+// printf("%s -> oid : %u\n",__func__,oid);
+
pthread_mutex_lock(&gclistlock);
threadcount++;
pthread_mutex_unlock(&gclistlock);