X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=blobdiff_plain;f=Robust%2Fsrc%2FRuntime%2FDSTM%2Finterface%2Fllookup.h;h=29c0d30471cd62db251756dcca87e3bb620a417e;hp=ffae96a207920d23f2099be8aaf3db610ff5d9d6;hb=4cb63e913202459da4fe9d01feb7c02f1b98dd6f;hpb=e4e64d2901fa755a0973dc363fc18798f2f44adc diff --git a/Robust/src/Runtime/DSTM/interface/llookup.h b/Robust/src/Runtime/DSTM/interface/llookup.h index ffae96a2..29c0d304 100644 --- a/Robust/src/Runtime/DSTM/interface/llookup.h +++ b/Robust/src/Runtime/DSTM/interface/llookup.h @@ -1,30 +1,40 @@ #ifndef _LLOOKUP_H_ #define _LLOOKUP_H_ -#define LOADFACTOR 0.75 +#include +#include +#include + +#define SIMPLE_LLOOKUP + +#define LOADFACTOR 0.5 #define HASH_SIZE 100 -typedef struct hashlistnode { +typedef struct lhashlistnode { unsigned int oid; unsigned int mid; - struct hashlistnode *next; + struct lhashlistnode *next; } lhashlistnode_t; -typedef struct hashtable { +typedef struct lhashtable { lhashlistnode_t *table; // points to beginning of hash table unsigned int size; unsigned int numelements; float loadfactor; + pthread_mutex_t locktable; } lhashtable_t; -/* Prototypes for hash*/ -lhashtable_t lhashCreate(unsigned int size, float loadfactor); -unsigned int lhashFunction(lhashtable_t table, unsigned int oid); -void lhashInsert(lhashtable_t table, unsigned int oid, unsigned int mid); -int lhashSearch(lhashtable_t table, unsigned int oid); //returns oid, -1 if not found -int lhashRemove(lhashtable_t table, unsigned int oid); //returns -1 if not found -void lhashResize(lhashtable_t table, unsigned int newsize); -/* end hash */ +//returns 0 for success and 1 for failure +unsigned int lhashCreate(unsigned int size, float loadfactor); +//returns 0 for success and 1 for failure +unsigned int lhashInsert(unsigned int oid, unsigned int mid); +//returns mid, 0 if not found +unsigned int lhashSearch(unsigned int oid); +//returns 0 for success and 1 for failure +unsigned int lhashRemove(unsigned int oid); -#endif +//helper functions +unsigned int lhashResize(unsigned int newsize); +unsigned int lhashFunction(unsigned int oid); +#endif