-#ifndef _MLOOKUP_H_
-#define _MLOOKUP_H_
+#ifndef _ALTMLOOKUP_H_
+#define _ALTMLOOKUP_H_
#include <stdlib.h>
#include <stdio.h>
}
inline int is_write_locked(volatile int *lock) {
- return lock < 0;
+ return lock <= 0;
}
inline int is_read_locked(volatile int *lock) {
#define MSG_NOSIGNAL 0
#endif
+#define CFENCE asm volatile("":::"memory");
/***********************************************************
* Macros
**********************************************************/
void randomdelay();
void transStart();
-//#define TRANSREAD(x,y,z(tobe passed as a parameter to transRead2)) {
+//#define TRANSREAD(x,y,z) /* Use "z" which is program point at which TRANSREAD is generated, use this as transRead2(inputvalue,z) */
#define TRANSREAD(x,y) { \
unsigned int inputvalue;\
if ((inputvalue=(unsigned int)y)==0) x=NULL;\
}
}
h = (objheader_t *) srcObj;
+ /* If object is write locked, just wait */
+ /* May want to remove at some point */
+ while((*(volatile int *)STATUSPTR(h))<=0)
+ sched_yield();
GETSIZE(size, h);
size += sizeof(objheader_t);
sockid = (int) acceptfd;
}
ptr = (char *) modptr;
for(i = 0 ; i < fixed.nummod; i++) {
- int tmpsize;
headaddr = (objheader_t *) ptr;
oid = OID(headaddr);
oidmod[i] = oid;
+ int tmpsize=0;
GETSIZE(tmpsize, headaddr);
ptr += sizeof(objheader_t) + tmpsize;
}
int incr = sizeof(unsigned int) + sizeof(unsigned short); // Offset that points to next position in the objread array
incr *= i;
oid = *((unsigned int *)(objread + incr));
+
incr += sizeof(unsigned int);
version = *((unsigned short *)(objread + incr));
retval=getCommitCountForObjRead(oidnotfound, oidlocked, oidvernotmatch, &objnotfound, &objlocked, &objvernotmatch,
dst->___cachedHash___=src->___cachedHash___;
memcpy(&dst[1], &src[1], tmpsize-sizeof(struct ___Object___));
}
+
+ //memory barrier
+ CFENCE;
+
header->version += 1;
/* If threads are waiting on this object to be updated, notify them */
if(header->notifylist != NULL) {
return;
}
+/********** for DEBUGGING **************/
+char ip[16]; // for debugging purpose
+char* midtoIPString(unsigned int mid){
+ midtoIP(mid, ip);
+ return ip;
+}
+
+/******************************/
+
+
+
int checkServer(int mid, char *machineip) {
int tmpsd;
struct sockaddr_in serv_addr;
void midtoIP(unsigned int, char *);
int checkServer(int, char *);
unsigned int getMyIpAddr(const char *interfaceStr);
+char* midtoIPString(unsigned int mid);
#endif
if (STATUS(headeraddr) & NEW) {
//new objects cannot be stale
} else if ((tmp=mhashSearch(curr->key)) != NULL) {
+ //memory barrier
+ CFENCE;
if (tmp->version!=headeraddr->version) {
//version mismatch
deletehead(head);
void handle();
extern pfcstats_t *evalPrefetch;
-/*
void transStatsHandler(int sig, siginfo_t* info, void *context) {
#ifdef TRANSSTATS
char filepath[200], exectime[10];
exit(0);
#endif
}
-*/
+
+/*
void transStatsHandler(int sig, siginfo_t* info, void *context) {
#ifdef TRANSSTATS
printf("****** Transaction Stats ******\n");
exit(0);
#endif
}
+*/
void handle() {
#ifdef TRANSSTATS
if(curr->key == 0)
break;
headeraddr=(objheader_t *) curr->val;
-
//Get machine location for object id (and whether local or not)
if (STATUS(headeraddr) & NEW || (mhashSearch(curr->key) != NULL)) {
machinenum = myIpAddr;
free(tosend);
return 1;
}
- GETSIZE(size,headeraddr);
+ GETSIZE(size,headeraddr);
size+=sizeof(objheader_t);
memcpy(modptr+offset, headeraddr, size);
offset+=size;
memcpy(&dst[1], &src[1], tmpsize-sizeof(struct ___Object___));
}
+ //memory barrier
+ CFENCE;
+
header->version += 1;
if(header->notifylist != NULL) {
notifyAll(&header->notifylist, OID(header), header->version);
t_chashDelete();
}
+
/* This function inserts necessary information into
* a machine pile data structure */
plistnode_t *pInsert(plistnode_t *pile, objheader_t *headeraddr, unsigned int mid, int num_objs) {
return pile;
}
+// relocate the position of myIp pile to end of list
plistnode_t *sortPiles(plistnode_t *pileptr) {
- plistnode_t *head, *ptr, *tail;
- head = pileptr;
- ptr = pileptr;
- /* Get tail pointer */
- while(ptr!= NULL) {
- tail = ptr;
- ptr = ptr->next;
- }
- ptr = pileptr;
- plistnode_t *prev = pileptr;
- /* Arrange local machine processing at the end of the pile list */
- while(ptr != NULL) {
- if(ptr != tail) {
- if(ptr->mid == myIpAddr && (prev != pileptr)) {
- prev->next = ptr->next;
- ptr->next = NULL;
- tail->next = ptr;
- return pileptr;
- }
- if((ptr->mid == myIpAddr) && (prev == pileptr)) {
- prev = ptr->next;
- ptr->next = NULL;
- tail->next = ptr;
- return prev;
- }
- prev = ptr;
- }
- ptr = ptr->next;
+ plistnode_t *ptr, *tail;
+ tail = pileptr;
+ ptr = NULL;
+ /* Get tail pointer and myIp pile ptr */
+ if(pileptr == NULL)
+ return pileptr;
+
+ while(tail->next != NULL) {
+ if(tail->mid == myIpAddr)
+ ptr = tail;
+ tail = tail->next;
+ }
+
+ // if ptr is null, then myIp pile is already at tail
+ if(ptr != NULL) {
+ /* Arrange local machine processing at the end of the pile list */
+ tail->next = pileptr;
+ pileptr = ptr->next;
+ ptr->next = NULL;
+ return pileptr;
}
+
+ /* get too this point iff myIpAddr pile is at tail */
return pileptr;
}