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 {
/* 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);
/* 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);
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