}
}
+ /** 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()) {
}
}
+ /** 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;
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<PrefetchPair> pset1 = new HashSet<PrefetchPair>();
HashSet<PrefetchPair> pset2 = new HashSet<PrefetchPair>();
}
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<PrefetchPair> s = new HashSet<PrefetchPair>();
- //if(!newpset.isEmpty() && !pset2.isEmpty()) {
if(!newpset.isEmpty()) {
if(!pset2.isEmpty()) {
for(Iterator it = newpset.iterator(); it.hasNext();) {
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
* 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;
}
void *buf;
struct timespec ts;
struct timeval tp;
+
+ if(oid == 0) {
+ return NULL;
+ }
rc = gettimeofday(&tp, NULL);
tmp->rcount = 1;
STATUS(tmp) = NEW;
chashInsert(record->lookupTable, OID(tmp), tmp);
+
#ifdef COMPILER
return &tmp[1]; //want space after object header
#else
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*/
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);
}
free(thread_data_array[i].buffer);
}
-
/* Free resources */
pthread_cond_destroy(&tcond);
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);
/* Close connection */
close(sd);
- pthread_exit(NULL);
+ //pthread_exit(NULL);
}
/* This function decides the reponse that needs to be sent to
free(localtdata->transinfo->objnotfound);
}
- pthread_exit(NULL);
+ //pthread_exit(NULL);
}
/* This function completes the ABORT process if the transaction is aborting */
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);