From: adash Date: Mon, 6 Apr 2009 18:36:19 +0000 (+0000) Subject: more changes (get rid of getnewOID and use TRANSREAD macro) X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=eb2c487d2302fe2f03f2f387d486a1c2f84fa8a9;p=IRC.git more changes (get rid of getnewOID and use TRANSREAD macro) --- diff --git a/Robust/src/Runtime/STM/stm.c b/Robust/src/Runtime/STM/stm.c index 0d3ec464..75e84dfa 100644 --- a/Robust/src/Runtime/STM/stm.c +++ b/Robust/src/Runtime/STM/stm.c @@ -11,27 +11,16 @@ */ #include "tm.h" - -/* ======================= - * Global variables - * ====================== - */ -unsigned int oidMin; -unsigned int oidMax; -extern int classsize[]; /* Thread transaction variables */ __thread objstr_t *t_cache; /* ================================================== - * dstmStartup + * stmStartup * This function starts up the transaction runtime. * ================================================== */ int stmStartup() { - oidMax = 0xFFFFFFFF; - oidMin = 0; - return 0; } @@ -83,16 +72,6 @@ objheader_t *transCreateObj(unsigned int size) { #endif } -//TODO: when reusing oids, make sure they are not already in use! -static unsigned int id = 0xFFFFFFFF; -unsigned int getNewOID(void) { - id += 2; - if (id > oidMax || id < oidMin) { - id = (oidMin | 1); - } - return id; -} - /* This functions inserts randowm wait delays in the order of msec * Mostly used when transaction commits retry*/ void randomdelay() { @@ -143,31 +122,15 @@ void *objstrAlloc(objstr_t **osptr, unsigned int size) { /* ============================================================= * transRead - * -finds the objects either in transaction cache or main heap + * -finds the objects either in main heap * -copies the object into the transaction cache * ============================================================= */ __attribute__((pure)) objheader_t *transRead(unsigned int oid) { - int size; + unsigned int machinenumber; + objheader_t *tmp, *objheader; objheader_t *objcopy; - chashlistnode_t *node; - - if(oid == 0) { - return NULL; - } - - /* Read from the transaction cache */ - node= &c_table[(oid & c_mask)>>1]; - do { - if(node->key == oid) { -#ifdef COMPILER - return &((objheader_t*)node->val)[1]; -#else - return node->val; -#endif - } - node = node->next; - } while(node != NULL); + int size; /* Read from the main heap */ objheader_t *header = (objheader_t *)(((char *)(&oid)) - sizeof(objheader_t)); diff --git a/Robust/src/Runtime/STM/tm.h b/Robust/src/Runtime/STM/tm.h index 485fe35b..60d21cad 100644 --- a/Robust/src/Runtime/STM/tm.h +++ b/Robust/src/Runtime/STM/tm.h @@ -38,9 +38,6 @@ #define NEW 0x02 #define LOCK 0x04 -//TODO Remove later -#define NUMCLASSES 22 - /* ================================ * Constants * ================================ @@ -48,6 +45,17 @@ #define DEFAULT_OBJ_STORE_SIZE 1048510 //1MB #define OSUSED(x) (((unsigned int)(x)->top)-((unsigned int) (x+1))) #define OSFREE(x) ((x)->size-OSUSED(x)) +#define TRANSREAD(x,y) { \ + unsigned int inputvalue;\ +if ((inputvalue=(unsigned int)y)==0) x=NULL;\ +else { \ +chashlistnode_t * cnodetmp=&c_table[(inputvalue&c_mask)>>1]; \ +do { \ + if (cnodetmp->key==inputvalue) {x=(void *)&((objheader_t*)cnodetmp->val)[1];break;} \ +cnodetmp=cnodetmp->next;\ + if (cnodetmp==NULL) {x=(void *)transRead(inputvalue); asm volatile("":"=m"(c_table),"=m"(c_mask));break;} \ +} while(1);\ +}} /* ================================= * Data structures @@ -97,6 +105,11 @@ typedef struct objheader { } #else +#define OID(x) x->oid +#define TYPE(x) x->type +#define STATUS(x) x->status +#define STATUSPTR(x) &x->status +#define GETSIZE(size, x) size=classsize[TYPE(x)] #endif /* ================================