From 8093a699b5be50efc844400504ccc628f94c5059 Mon Sep 17 00:00:00 2001 From: adash Date: Thu, 20 Dec 2007 00:07:04 +0000 Subject: [PATCH] minor changes --- .../Analysis/Prefetch/PrefetchAnalysis.java | 15 +++++++++-- Robust/src/Runtime/DSTM/interface/dstm.h | 2 +- Robust/src/Runtime/DSTM/interface/trans.c | 26 +++++++++++-------- Robust/src/Tests/Atomic4.java | 6 ++--- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java b/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java index 4b649a8e..6296abdc 100644 --- a/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java +++ b/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java @@ -1235,6 +1235,9 @@ public class PrefetchAnalysis { } } + /** This function deletes the smaller prefetch pair subset from a list of prefetch pairs + * for e.g. if there are 2 prefetch pairs a.b.c.d and a.b.c for a given flatnode + * then this function drops a.b.c from the prefetch set of the flatnode */ private void delSubsetPPairs() { Enumeration e = prefetch_hash.keys(); while(e.hasMoreElements()) { @@ -1278,6 +1281,8 @@ public class PrefetchAnalysis { } } + /** This function returns: true if the shorter prefetch pair is a subset of the longer prefetch + * pair else it returns: false */ private boolean isSubSet(PrefetchPair shrt, PrefetchPair lng) { if (shrt.base != lng.base) { return false; @@ -1323,6 +1328,11 @@ public class PrefetchAnalysis { return hasChanged; } + /** This function creates a set called pset1 that contains prefetch pairs that have already + * been prefetched. While traversing the graph of a flat representation in a top down fashion, + * this function creates pset1 such that it contains prefetch pairs that have been prefetched at + * the previous nodes */ + private void applyPrefetchInsertRules(FlatNode fn) { HashSet pset1 = new HashSet(); HashSet pset2 = new HashSet(); @@ -1431,9 +1441,10 @@ public class PrefetchAnalysis { } pset1_hash.put(fn, pset1); - /* To insert prefetch apply rule */ + + /* To insert prefetch apply rule: if the newpset intersection pset2 is nonempty + * then insert a new prefetch node here*/ HashSet s = new HashSet(); - //if(!newpset.isEmpty() && !pset2.isEmpty()) { if(!newpset.isEmpty()) { if(!pset2.isEmpty()) { for(Iterator it = newpset.iterator(); it.hasNext();) { diff --git a/Robust/src/Runtime/DSTM/interface/dstm.h b/Robust/src/Runtime/DSTM/interface/dstm.h index 99a21fbd..917e546e 100644 --- a/Robust/src/Runtime/DSTM/interface/dstm.h +++ b/Robust/src/Runtime/DSTM/interface/dstm.h @@ -142,7 +142,7 @@ typedef struct trans_req_data { unsigned int *listmid; /* Pointer to array holding list of participants */ char *objread; /* Pointer to array holding oid and version number of objects that are only read */ unsigned int *oidmod; /* Pointer to array holding oids of objects that are modified */ - unsigned int *oidcreated; /* Pointer to array holding oids of objects that are newly created */ + unsigned int *oidcreated; /* Pointer to array holding oids of objects that are newly created */ } trans_req_data_t; /* Structure that holds information of objects that are not found in the participant diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index c65127f5..26facf03 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -216,13 +216,12 @@ void transExit() { * Mostly used when transaction commits retry*/ void randomdelay(void) { - struct timespec req, rem; + struct timespec req; time_t t; t = time(NULL); req.tv_sec = 0; req.tv_nsec = (long)(1000000 + (t%10000000)); //1-11 msec - //nanosleep(&req, &rem); nanosleep(&req, NULL); return; } @@ -249,6 +248,10 @@ objheader_t *transRead(transrecord_t *record, unsigned int oid) { void *buf; struct timespec ts; struct timeval tp; + + if(oid == 0) { + return NULL; + } rc = gettimeofday(&tp, NULL); @@ -346,6 +349,7 @@ objheader_t *transCreateObj(transrecord_t *record, unsigned int size) tmp->rcount = 1; STATUS(tmp) = NEW; chashInsert(record->lookupTable, OID(tmp), tmp); + #ifdef COMPILER return &tmp[1]; //want space after object header #else @@ -423,6 +427,7 @@ int transCommit(transrecord_t *record) { do { trecvcount = 0; threadnum = 0; + treplyretry = 0; /* Look through all the objects in the transaction record and make piles * for each machine involved in the transaction*/ @@ -519,9 +524,9 @@ int transCommit(transrecord_t *record) { thread_data_array[threadnum].rec = record; /* If local do not create any extra connection */ if(pile->mid != myIpAddr) { /* Not local */ - do { - rc = pthread_create(&thread[threadnum], &attr, transRequest, (void *) &thread_data_array[threadnum]); - } while(rc!=0); + do { + rc = pthread_create(&thread[threadnum], &attr, transRequest, (void *) &thread_data_array[threadnum]); + } while(rc!=0); if(rc) { perror("Error in pthread create\n"); pthread_cond_destroy(&tcond); @@ -581,7 +586,6 @@ int transCommit(transrecord_t *record) { } free(thread_data_array[i].buffer); } - /* Free resources */ pthread_cond_destroy(&tcond); @@ -591,11 +595,11 @@ int transCommit(transrecord_t *record) { free(thread_data_array); free(ltdata); - /* wait a random amount of time */ - if (treplyretry == 1) { + /* wait a random amount of time before retrying to commit transaction*/ + if(treplyretry == 1) { randomdelay(); } - + /* Retry trans commit procedure if not sucessful in the first try */ } while (treplyretry == 1); @@ -712,7 +716,7 @@ void *transRequest(void *threadarg) { /* Close connection */ close(sd); - pthread_exit(NULL); + //pthread_exit(NULL); } /* This function decides the reponse that needs to be sent to @@ -993,7 +997,7 @@ void *handleLocalReq(void *threadarg) { free(localtdata->transinfo->objnotfound); } - pthread_exit(NULL); + //pthread_exit(NULL); } /* This function completes the ABORT process if the transaction is aborting */ diff --git a/Robust/src/Tests/Atomic4.java b/Robust/src/Tests/Atomic4.java index e180164c..563acbf9 100644 --- a/Robust/src/Tests/Atomic4.java +++ b/Robust/src/Tests/Atomic4.java @@ -1,17 +1,17 @@ public class Atomic4 extends Thread { - People[] team; + public People[] team; public Atomic4() { - People[] team = new People[2]; } public static void main(String[] st) { int mid = (128<<24)|(195<<16)|(175<<8)|70; - int b,c; + int b = 0,c = 0; Integer age; String name; Atomic4 at4 = null; atomic { at4 = global new Atomic4(); + at4.team = global new People[2]; at4.team[0] = global new People(); at4.team[1] = global new People(); age = global new Integer(35); -- 2.34.1