From: bdemsky Date: Thu, 16 Aug 2007 08:45:59 +0000 (+0000) Subject: more changes... X-Git-Tag: preEdgeChange~473 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=0331b770ec892e9fad3f94f93f448be1785ef539;p=IRC.git more changes... actually can compile programs in dstm mode if they don't use the dsm --- diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index ee496ad9..e645038d 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -179,7 +179,7 @@ public class BuildCode { outmethod.println("int main(int argc, const char *argv[]) {"); outmethod.println(" int i;"); if (state.DSM) { - outmethod.println("if (dstmStart(argv[0])) {"); + outmethod.println("if (dstmStartup(argv[1])) {"); if (GENERATEPRECISEGC) { outmethod.println(" struct ArrayObject * stringarray=allocate_newarray(NULL, STRINGARRAYTYPE, argc-2);"); } else { diff --git a/Robust/src/Runtime/DSTM/interface/dstm.h b/Robust/src/Runtime/DSTM/interface/dstm.h index c96f1464..87899bb8 100644 --- a/Robust/src/Runtime/DSTM/interface/dstm.h +++ b/Robust/src/Runtime/DSTM/interface/dstm.h @@ -189,11 +189,6 @@ transrecord_t *record; /* Initialize main object store and lookup tables, start server thread. */ int dstmInit(void); -/* Function called at beginning. Passes in the first parameter. */ -/* Returns 1 if this thread should run the main process */ - -int dstmStart(char *); - /* Prototypes for object header */ unsigned int getNewOID(void); unsigned int objSize(objheader_t *object); @@ -216,6 +211,12 @@ int transCommitProcess(trans_commit_data_t *, int); /* end server portion */ /* Prototypes for transactions */ +/* Function called at beginning. Passes in the first parameter. */ +/* Returns 1 if this thread should run the main process */ + +int dstmStartup(char *); +void transInit(); + void randomdelay(void); transrecord_t *transStart(); objheader_t *transRead(transrecord_t *, unsigned int); diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index e5c9a06b..67c56629 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -80,6 +80,29 @@ void prefetch(int ntuples, unsigned int *oids, short *endoffsets, short *arrayfi pthread_mutex_unlock(&pqueue.qlock); } + +/* This function starts up the transaction runtime. */ +int dstmStartup(char * option) { + pthread_t thread_Listen; + pthread_attr_t attr; + int master=strcmp(option, "master")==0; + + dstmInit(); + transInit(); + + if (master) { + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + pthread_create(&thread_Listen, &attr, dstmListen, NULL); + return 1; + } else { + dstmListen(); + return 0; + } + +} + + /* This function initiates the prefetch thread * A queue is shared between the main thread of execution * and the prefetch thread to process the prefetch call