From 31d3823e372b72716c243fac343d50cd62f7b092 Mon Sep 17 00:00:00 2001 From: adash Date: Wed, 14 Mar 2007 22:40:20 +0000 Subject: [PATCH] *** empty log message *** --- Robust/src/Runtime/DSTM/interface/dstm.h | 1 + .../src/Runtime/DSTM/interface/dstmserver.c | 5 +- Robust/src/Runtime/DSTM/interface/objstr.c | 2 - Robust/src/Runtime/DSTM/interface/trans.c | 47 +++++++++++++++---- 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/Robust/src/Runtime/DSTM/interface/dstm.h b/Robust/src/Runtime/DSTM/interface/dstm.h index fdfd0951..ad02018f 100644 --- a/Robust/src/Runtime/DSTM/interface/dstm.h +++ b/Robust/src/Runtime/DSTM/interface/dstm.h @@ -6,6 +6,7 @@ #include #include "clookup.h" +#define DEFAULT_OBJ_STORE_SIZE 1048510 //1MB //bit designations for status field of objheader #define DIRTY 0x01 #define NEW 0x02 diff --git a/Robust/src/Runtime/DSTM/interface/dstmserver.c b/Robust/src/Runtime/DSTM/interface/dstmserver.c index 49a5dc4b..fcc57a65 100644 --- a/Robust/src/Runtime/DSTM/interface/dstmserver.c +++ b/Robust/src/Runtime/DSTM/interface/dstmserver.c @@ -13,12 +13,15 @@ #define RECIEVE_BUFFER_SIZE 1500 +objstr_t *mainobjstore; +mainobjstore = objstrCreate(DEFAULT_OBJ_STORE_SIZE); + int dstmInit(void) { //todo:initialize main object store //do we want this to be a global variable, or provide //separate access funtions and hide the structure? - + if (mhashCreate(HASH_SIZE, LOADFACTOR)) return 1; //failure diff --git a/Robust/src/Runtime/DSTM/interface/objstr.c b/Robust/src/Runtime/DSTM/interface/objstr.c index 216a5bcf..4a66fa54 100644 --- a/Robust/src/Runtime/DSTM/interface/objstr.c +++ b/Robust/src/Runtime/DSTM/interface/objstr.c @@ -1,7 +1,5 @@ #include "dstm.h" -#define DEFAULT_OBJ_STORE_SIZE 1048510 //1MB - objstr_t *objstrCreate(unsigned int size) { objstr_t *tmp = malloc(sizeof(objstr_t) + size); diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index d2971df7..90507f5e 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -3,36 +3,63 @@ #include "mlookup.h" #include "llookup.h" +extern int classsize[]; + transrecord_t *transStart() { transrecord_t *tmp = malloc(sizeof(transrecord_t)); tmp->cache = objstrCreate(1048576); - tmp->lookupTable = cachehashCreate(HASH_SIZE, LOADFACTOR); + tmp->lookupTable = chashCreate(HASH_SIZE, LOADFACTOR); return tmp; } objheader_t *transRead(transrecord_t *record, unsigned int oid) -{ +{ + unsigned int machinenumber; + + objheader_t *tmp, *objheader; + void *objcopy; + int size; //check cache - //else check machine lookup table - //else check location lookup table - //else broadcast + if((objheader =(objheader_t *)chashSearch(record->lookupTable, oid)) != NULL){ + return(objheader); + } else if ((objheader = (objheader_t *) mhashSearch(oid)) != NULL) { + //Look up in Machine lookup table and found + printf(" oid not found in cache\n"); + tmp = mhashSearch(oid); + size = sizeof(objheader_t)+classsize[tmp->type]; + //Copy into cache + objcopy = objstrAlloc(record->cache, size); + memcpy(objcopy, (void *)tmp, size); + //Insert into cache's lookup table + chashInsert(record->lookupTable, objheader->oid, objcopy); + return(objcopy); + } else { + printf(" oid not found in Machine Lookup\n"); + machinenumber = lhashSearch(oid); + //TODO:broadcast + return(NULL); + } } + objheader_t *transCreateObj(transrecord_t *record, unsigned short type) { - objheader_t *tmp = objstrAlloc(record->cache, classsize[type]); + objheader_t *tmp = (objheader_t *) objstrAlloc(record->cache, classsize[type]); tmp->oid = getNewOID(); tmp->type = type; tmp->version = 1; tmp->rcount = 0; //? not sure how to handle this yet tmp->status |= NEW; - cachehashInsert(record->lookupTable, tmp->oid, tmp); + chashInsert(record->lookupTable, tmp->oid, tmp); return tmp; } -int transCommit(transrecord_t *record) -{ - +int transCommit(transrecord_t *record){ + //Move objects to machine that hosts it + } +int transAbort(transrecord_t *record){ + +} -- 2.34.1