Added trans.c for transaction funtions. Implemented transStart() and transCreateObj...
authorerubow <erubow>
Sat, 10 Mar 2007 00:21:57 +0000 (00:21 +0000)
committererubow <erubow>
Sat, 10 Mar 2007 00:21:57 +0000 (00:21 +0000)
Added dstmInit() to dstmserver.c
Resolved a name conflict in *lookup.h's: the structs had the same name, so I prefixed them with m,l, or cache to match the typedef.
In dstm.h: defined DIRTY and NEW bits for objheader status flag.

Robust/src/Runtime/DSTM/interface/clookup.h
Robust/src/Runtime/DSTM/interface/dstm.h
Robust/src/Runtime/DSTM/interface/dstmserver.c
Robust/src/Runtime/DSTM/interface/llookup.h
Robust/src/Runtime/DSTM/interface/mlookup.h
Robust/src/Runtime/DSTM/interface/trans.c [new file with mode: 0644]

index a90d9287e55b38f4ee87115506939541cc1fec62..9425102f717959ab6be837c4fe7e75dc29bf6b00 100644 (file)
@@ -7,13 +7,13 @@
 #define LOADFACTOR 0.75
 #define HASH_SIZE 100
 
-typedef struct hashlistnode {
+typedef struct cachehashlistnode {
        unsigned int key;
        void *val; //this can be cast to another type or used to point to a larger structure
-       struct hashlistnode *next;
+       struct cachehashlistnode *next;
 } cachehashlistnode_t;
 
-typedef struct hashtable {
+typedef struct cashehashtable {
        cachehashlistnode_t *table;     // points to beginning of hash table
        unsigned int size;
        unsigned int numelements;
index 9651f3dc7533029e1afb5cb9f73bfdf4c556858a..d7278ea6052ee12acc6a082bc49f9f3a6ee07180 100644 (file)
@@ -4,8 +4,11 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include "clookup.h"
 
-enum status {CLEAN, DIRTY};
+//bit designations for status field of objheader
+#define DIRTY 0x01
+#define NEW   0x02
 
 typedef struct objheader {
        unsigned int oid;
@@ -23,11 +26,11 @@ typedef struct objstr {
 
 typedef struct transrecord {
        objstr_t *cache;
-       hashtable_t *lookupTable;
+       cachehashtable_t *lookupTable;
 } transrecord_t;
 
 /* Initialize main object store and lookup tables, start server thread. */
-void dstmInit(void);
+int dstmInit(void);
 
 /* Prototypes for object header */
 unsigned int getNewOID(void);
index 998ff51435826d60103e6c98b905a7e36203f817..49a5dc4b6768eaa2e8cd8b12db218b630c9b25e2 100644 (file)
@@ -4,12 +4,33 @@
 #include <pthread.h>
 #include <netdb.h>
 #include <fcntl.h>
-#include "dstmserver.h"
+#include "dstm.h"
+#include "mlookup.h"
+#include "llookup.h"
 
 #define LISTEN_PORT 2153
 #define BACKLOG 10 //max pending connections
 #define RECIEVE_BUFFER_SIZE 1500
 
+
+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
+       
+       if (lhashCreate(HASH_SIZE, LOADFACTOR))
+               return 1; //failure
+       
+       pthread_t threadListen;
+       pthread_create(&threadListen, NULL, dstmListen, NULL);
+       
+       return 0;
+}
+
 void *dstmListen()
 {
        int listenfd, acceptfd;
index f936078f67520f0313f0a478d89b505f9b790d8e..719e68cb89bb6e45ccbd1d20a78db92e7ddb51dd 100644 (file)
@@ -7,13 +7,13 @@
 #define LOADFACTOR 0.75
 #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;
index b2f812192f7f1dfa0eb52ff9db95c7338dd1999f..9e45b88096781dd1dd1d0daa91f2e9fe61a61cb0 100644 (file)
@@ -7,13 +7,13 @@
 #define LOADFACTOR 0.75
 #define HASH_SIZE 100
 
-typedef struct hashlistnode {
+typedef struct mhashlistnode {
        unsigned int key;
        void *val; //this can be cast to another type or used to point to a larger structure
-       struct hashlistnode *next;
+       struct mhashlistnode *next;
 } mhashlistnode_t;
 
-typedef struct hashtable {
+typedef struct mhashtable {
        mhashlistnode_t *table; // points to beginning of hash table
        unsigned int size;
        unsigned int numelements;
diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c
new file mode 100644 (file)
index 0000000..d2971df
--- /dev/null
@@ -0,0 +1,38 @@
+#include "dstm.h"
+#include "clookup.h"
+#include "mlookup.h"
+#include "llookup.h"
+
+transrecord_t *transStart()
+{
+       transrecord_t *tmp = malloc(sizeof(transrecord_t));
+       tmp->cache = objstrCreate(1048576);
+       tmp->lookupTable = cachehashCreate(HASH_SIZE, LOADFACTOR);
+       return tmp;
+}
+
+objheader_t *transRead(transrecord_t *record, unsigned int oid)
+{
+               //check cache
+               //else check machine lookup table
+               //else check location lookup table
+               //else broadcast
+}
+
+objheader_t *transCreateObj(transrecord_t *record, unsigned short type)
+{
+       objheader_t *tmp = 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);
+       return tmp;
+}
+
+int transCommit(transrecord_t *record)
+{
+       
+}
+