#include <errno.h>
#include <time.h>
#include "sockpool.h"
+#include "prelookup.h"
//bit designations for status field of objheader
#define DIRTY 0x01
objstr_t *objstrCreate(unsigned int size); //size in bytes
void objstrDelete(objstr_t *store); //traverse and free entire list
void *objstrAlloc(objstr_t *store, unsigned int size); //size in bytes
+void clearObjStore(); // TODO:currently only clears the prefetch cache object store
/* end object store */
/* Prototypes for server portion */
#include "dstm.h"
+extern objstr_t *prefetchcache;
objstr_t *objstrCreate(unsigned int size) {
objstr_t *tmp = calloc(1, (sizeof(objstr_t) + size));
}
}
+void clearObjStore() {
+ objstr_t *tmp = prefetchcache;
+ while(tmp != NULL) {
+ bzero(tmp+1, tmp->size);
+ tmp = tmp->next;
+ }
+}
free(ptr);
}
+
+//Note: This is based on the implementation of the inserting a key in the first position of the hashtable
+void prehashClear() {
+ int i, isFirstBin;
+ prehashlistnode_t *ptr, *prev, *curr;
+
+ pthread_mutex_lock(&pflookup.lock);
+ ptr = pflookup.table;
+ for(i = 0; i < pflookup.size; i++) {
+ prev = &ptr[i];
+ isFirstBin = 1;
+ while(prev->next != NULL) {
+ isFirstBin = 0;
+ curr = prev->next;
+ prev->next = curr->next;
+ free(curr);
+ }
+ if(isFirstBin == 1) {
+ prev->key = 0;
+ prev->next = NULL;
+ }
+ }
+ pthread_mutex_unlock(&pflookup.lock);
+}
+
void *prehashSearch(unsigned int key); //returns val, NULL if not found
unsigned int prehashRemove(unsigned int key); //returns -1 if not found
unsigned int prehashResize(unsigned int newsize);
+void prehashClear();
/* end hash */
#endif
#include "option.h"
#ifdef DSTM
#include "dstm.h"
+#include "prelookup.h"
#endif
extern int classsize[];
}
}
+#ifdef DSTM
+void CALL00(___System______clearPrefetchCache____) {
+ clearObjStore();
+ prehashClear();
+}
+#endif
+
/* Object allocation function */
#ifdef DSTM