7ac0706a59af55bf5bbadf59fa92f891524a231f
[IRC.git] / Robust / src / Runtime / DSTM / interface / dstm.h
1 #ifndef _DSTM_H_
2 #define _DSTM_H_
3
4 //Client Messages
5 #define READ_REQUEST            1
6 #define READ_MULT_REQUEST       2
7 #define MOVE_REQUEST            3
8 #define MOVE_MULT_REQUEST       4
9 #define TRANS_REQUEST           5
10 #define TRANS_ABORT             6
11 #define TRANS_COMMIT            7
12
13 //Server Messages
14 #define OBJECT_FOUND            8
15 #define OBJECT_NOT_FOUND        9
16 #define OBJECTS_FOUND           10
17 #define OBJECTS_NOT_FOUND       11
18 #define TRANS_AGREE             12
19 #define TRANS_DISAGREE          13//for soft abort
20 #define TRANS_DISAGREE_ABORT    14//for hard abort
21 #define TRANS_SUCESSFUL         15//Not necessary for now
22
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26 #include "clookup.h"
27
28 #define DEFAULT_OBJ_STORE_SIZE 1048510 //1MB
29 //bit designations for status field of objheader
30 #define DIRTY 0x01
31 #define NEW   0x02
32 #define LOCK  0x04
33
34 typedef struct objheader {
35         unsigned int oid;
36         unsigned short type;
37         unsigned short version;
38         unsigned short rcount;
39         char status;
40 } objheader_t;
41
42 typedef struct objstr {
43         unsigned int size; //this many bytes are allocated after this header
44         void *top;
45         struct objstr *next;
46 } objstr_t;
47
48 typedef struct transrecord {
49         objstr_t *cache;
50         chashtable_t *lookupTable;
51 } transrecord_t;
52
53 typedef struct pile {
54         unsigned int mid;
55         unsigned int oid;
56         struct pile *next;
57 }pile_t;
58
59 /* Initialize main object store and lookup tables, start server thread. */
60 int dstmInit(void);
61
62 /* Prototypes for object header */
63 unsigned int getNewOID(void);
64 unsigned int objSize(objheader_t *object);
65 /* end object header */
66
67 /* Prototypes for object store */
68 objstr_t *objstrCreate(unsigned int size); //size in bytes
69 void objstrDelete(objstr_t *store); //traverse and free entire list
70 void *objstrAlloc(objstr_t *store, unsigned int size); //size in bytes
71 /* end object store */
72
73 /* Prototypes for server portion */
74 void *dstmListen();
75 void *dstmAccept(void *);
76 /* end server portion */
77
78 /* Prototypes for transactions */
79 transrecord_t *transStart();
80 objheader_t *transRead(transrecord_t *record, unsigned int oid);
81 objheader_t *transCreateObj(transrecord_t *record, unsigned short type); //returns oid
82 int transCommit(transrecord_t *record); //return 0 if successful
83 /* end transactions */
84
85 void *getRemoteObj(transrecord_t *, unsigned int, unsigned int);
86
87 #endif