*** empty log message ***
authoradash <adash>
Wed, 14 Mar 2007 22:40:20 +0000 (22:40 +0000)
committeradash <adash>
Wed, 14 Mar 2007 22:40:20 +0000 (22:40 +0000)
Robust/src/Runtime/DSTM/interface/dstm.h
Robust/src/Runtime/DSTM/interface/dstmserver.c
Robust/src/Runtime/DSTM/interface/objstr.c
Robust/src/Runtime/DSTM/interface/trans.c

index fdfd0951a349e16502d1b51f99bb48e382b0742f..ad02018f5d133a694d5baa279ab767d53a44537b 100644 (file)
@@ -6,6 +6,7 @@
 #include <string.h>
 #include "clookup.h"
 
+#define DEFAULT_OBJ_STORE_SIZE 1048510 //1MB
 //bit designations for status field of objheader
 #define DIRTY 0x01
 #define NEW   0x02
index 49a5dc4b6768eaa2e8cd8b12db218b630c9b25e2..fcc57a658c046965c38e33ce4e11add6962b4ba2 100644 (file)
 #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
        
index 216a5bcf7ead1b2a6313962386ae5366710d7674..4a66fa54565f9e81d87e310c58395f4dd6aec7a6 100644 (file)
@@ -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);
index d2971df79477c6426ac171351b44c57afd53c5f5..90507f5e2554b389b6d21498cac29e49e4f68b7d 100644 (file)
@@ -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){
+
+}