From 6eaf123a3687c8f0608833035a5fb8c3e793b75e Mon Sep 17 00:00:00 2001 From: yeom Date: Thu, 3 Dec 2009 19:52:56 +0000 Subject: [PATCH] changes. --- .../src/Runtime/DSTM/interface/altprelookup.c | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/Robust/src/Runtime/DSTM/interface/altprelookup.c b/Robust/src/Runtime/DSTM/interface/altprelookup.c index bc92f0b6..72a34011 100644 --- a/Robust/src/Runtime/DSTM/interface/altprelookup.c +++ b/Robust/src/Runtime/DSTM/interface/altprelookup.c @@ -18,7 +18,7 @@ unsigned int prehashCreate(unsigned int size, float loadfactor) { } pflookup.table = nodes; pflookup.size = size; - pflookup.mask = (size << 1) -1; + pflookup.mask = size -1; pflookup.numelements = 0; // Initial number of elements in the hash pflookup.loadfactor = loadfactor; pflookup.threshold=loadfactor*size; @@ -28,19 +28,6 @@ unsigned int prehashCreate(unsigned int size, float loadfactor) { pflookup.larray[i].lock=RW_LOCK_BIAS; } - /* - //Intiliaze and set prefetch table mutex attribute - pthread_mutexattr_init(&pflookup.prefetchmutexattr); - //NOTE:PTHREAD_MUTEX_RECURSIVE is currently inside a #if_def UNIX98 in the pthread.h file - //Therefore use PTHREAD_MUTEX_RECURSIVE_NP instead - pthread_mutexattr_settype(&pflookup.prefetchmutexattr, PTHREAD_MUTEX_RECURSIVE_NP); - - //Initialize mutex var - pthread_mutex_init(&pflookup.lock, &pflookup.prefetchmutexattr); - //pthread_mutex_init(&pflookup.lock, NULL); - pthread_cond_init(&pflookup.cond, NULL); - */ - return 0; } @@ -80,6 +67,7 @@ void prehashInsert(unsigned int key, void *val) { isFound=1; tmp->val = val;//Replace value for an exsisting key write_unlock(lockptr); + return; } tmp=tmp->next; @@ -125,7 +113,6 @@ unsigned int prehashRemove(unsigned int key) { prehashlistnode_t *prev; prehashlistnode_t *ptr, *node; - //eom unsigned int keyindex=key>>1; volatile unsigned int * lockptr=&pflookup.larray[keyindex&LOCKMASK].lock; @@ -134,8 +121,7 @@ unsigned int prehashRemove(unsigned int key) { } prehashlistnode_t *curr = &pflookup.table[keyindex&pflookup.mask]; - //eom - + for (; curr != NULL; curr = curr->next) { if (curr->key == key) { // Find a match in the hash table @@ -249,7 +235,7 @@ else if (isfirst) { volatile unsigned int * lockptr=&pflookup.larray[i].lock; write_unlock(lockptr); } - return 0; + return ; } //Note: This is based on the implementation of the inserting a key in the first position of the hashtable -- 2.34.1