printf("nummod: %d, numlocked: %d\n", nummod, numlocked);
#endif
+ char* ptr;
+ objheader_t* headaddr;
+ objheader_t* ttmp;
+ ptr = (char *) modptr;
+ for(i = 0 ; i < nummod; i++){
+ int tmpsize=0;
+ headaddr = (objheader_t *) ptr;
+// printf("44 before OID = %u version = %d Type = %d\n",OID(headaddr),headaddr->version,TYPE(headaddr));
+ ttmp = (objheader_t*)mhashSearch(oidmod[i]);
+ if(ttmp != NULL && TYPE(ttmp) != TYPE(headaddr)) {
+ printf("before OID = %u Type = %d\n",OID(headaddr),TYPE(headaddr));
+ printf("After OID = %u Type = %d\n",OID(ttmp),TYPE(ttmp));
+ printf("\n");
+ }
+// printf("44 after OID = %u version = %d Type = %d\n",OID(headaddr),headaddr->version,TYPE(headaddr));
+// else
+// printf("44 after OID = %u version = %d Type = %d\n",OID(ttmp),ttmp->version,TYPE(ttmp));
+ GETSIZE(tmpsize, headaddr);
+ ptr += sizeof(objheader_t) + tmpsize;
+ }
+
/* Process each modified object saved in the mainobject store */
for(i = 0; i < nummod; i++) {
if((header = (objheader_t *) mhashSearch(oidmod[i])) == NULL) {
dst->___cachedHash___=src->___cachedHash___;
memcpy(&dst[1], &src[1], tmpsize-sizeof(struct ___Object___));
}
+ CFENCE;
header->version += 1;
#ifdef DEBUG
printf("oid: %u, new header version: %d\n", oidmod[i], header->version);
extern tlist_t* transList;
extern pthread_mutex_t translist_mutex;
extern pthread_mutex_t clearNotifyList_mutex;
+pthread_mutex_t oidlock;
+pthread_mutex_t tidlock;
+
unsigned int currentEpoch;
unsigned int currentBackupMachine;
pthread_mutex_init(&prefetchcache_mutex, &prefetchcache_mutex_attr);
pthread_mutex_init(¬ifymutex, NULL);
pthread_mutex_init(&atomicObjLock, NULL);
+#ifdef RECOVERY
+ pthread_mutex_init(&oidlock,NULL);
+ pthread_mutex_init(&tidlock,NULL);
+#endif
+
+
#ifdef CACHE
//Create prefetch cache lookup table
if(prehashCreate(PHASH_SIZE, PLOADFACTOR)) {
/* This function creates objects in the transaction record */
objheader_t *transCreateObj(unsigned int size) {
+ pthread_mutex_lock(&oidlock);
objheader_t *tmp = (objheader_t *) objstrAlloc(&t_cache, (sizeof(objheader_t) + size));
OID(tmp) = getNewOID();
tmp->notifylist = NULL;
tmp->isBackup = 0;
STATUS(tmp) = NEW;
t_chashInsert(OID(tmp), tmp);
+ pthread_mutex_unlock(&oidlock);
#ifdef COMPILER
return &tmp[1]; //want space after object header
#else
memcpy(&dst[1], &src[1], tmpsize-sizeof(struct ___Object___));
}
+ // memory barrier
+ CFENCE;
+
header->version += 1;
if(header->notifylist != NULL) {
#ifdef RECOVERY
#ifdef RECOVERY
static unsigned int tid = 0xFFFFFFFF;
unsigned int getNewTransID(void) {
- tid++;
+ pthread_mutex_lock(&tidlock);
+ tid+=2;
if (tid > transIDMax || tid < transIDMin) {
tid = (transIDMin | 1);
}
+ pthread_mutex_unlock(&tidlock);
return tid;
}
#endif