10 #define READ_MULT_REQUEST 2
11 #define MOVE_REQUEST 3
12 #define MOVE_MULT_REQUEST 4
13 #define TRANS_REQUEST 5
15 #define TRANS_COMMIT 7
16 #define TRANS_PREFETCH 8
17 #define TRANS_ABORT_BUT_RETRY_COMMIT_WITH_RELOCATING 9
19 //Participant Messages
20 #define OBJECT_FOUND 10
21 #define OBJECT_NOT_FOUND 11
22 #define OBJECTS_FOUND 12
23 #define OBJECTS_NOT_FOUND 13
24 #define TRANS_AGREE 17
25 #define TRANS_DISAGREE 18
26 #define TRANS_AGREE_BUT_MISSING_OBJECTS 19
27 #define TRANS_SOFT_ABORT 20
28 #define TRANS_SUCESSFUL 21
30 //Control bits for status of objects in Machine pile
31 #define OBJ_LOCKED_BUT_VERSION_MATCH 14
32 #define OBJ_UNLOCK_BUT_VERSION_MATCH 15
33 #define VERSION_NO_MATCH 16
35 //Max number of objects
36 #define MAX_OBJECTS 20
46 #define DEFAULT_OBJ_STORE_SIZE 1048510 //1MB
48 //bit designations for status field of objheader
54 typedef struct objheader {
57 unsigned short version;
58 unsigned short rcount;
62 typedef struct objstr {
63 unsigned int size; //this many bytes are allocated after this header
68 typedef struct transrecord {
70 chashtable_t *lookupTable;
72 // Structure that keeps track of responses from the participants
73 typedef struct thread_response {
77 // Structure that holds fixed data sizes to be sent along with TRANS_REQUEST
78 typedef struct fixed_data {
80 char trans_id[TID_LEN];
81 int mcount; // Machine count
82 short numread; // Number of objects read
83 short nummod; // Number of objects modified
84 int sum_bytes; // Total bytes modified
87 // Structure that holds variable data sizes per machine participant
88 typedef struct trans_req_data {
90 unsigned int *listmid;
95 // Structure passed to dstmAcceptinfo() on server side to complete TRANS_COMMIT process
96 typedef struct trans_commit_data{
98 unsigned int *objlocked;
99 unsigned int *objnotfound;
104 }trans_commit_data_t;
107 #define PRINT_TID(PTR) printf("DEBUG -> %x %d\n", PTR->mid, PTR->thread_id);
108 //structure for passing multiple arguments to thread
109 typedef struct thread_data_array {
113 trans_req_data_t *buffer;
114 thread_response_t *recvmsg;//shared datastructure to keep track of the control message receiv
115 pthread_cond_t *threshold; //threshhold for waking up a thread
116 pthread_mutex_t *lock; //lock the count variable
117 int *count; //variable to count responses of TRANS_REQUEST protocol from all participants
118 char *replyctrl; //shared ctrl message that stores the reply to be sent, filled by decideResp
119 char *replyretry; //shared variable to find out if we need retry (TRANS_COMMIT case)
120 transrecord_t *rec; // To send modified objects
121 } thread_data_array_t;
124 //Structure for passing arguments to the local m/c thread
125 typedef struct local_thread_data_array {
126 thread_data_array_t *tdata;
127 trans_commit_data_t *transinfo; //Required for trans commit process
128 } local_thread_data_array_t;
130 // Structure to save information about an oid necesaary for the decideControl()
131 typedef struct objinfo {
133 int poss_val; //Status of object(locked but version matches, version mismatch, oid not present in machine etc)
136 //Structure for members within prefetch tuples
137 typedef struct member {
144 //Structure for prefetching tuples generated by teh compiler
145 typedef struct prefetchpile{
150 struct prefetchpile *next;
153 //Structure per Oid in the prefetch call
156 //Structure that holds the compiler generated prefetch data
157 typedef struct compprefetchdata {
158 transrecord_t *record;
159 } compprefetchdata_t;
162 /* Initialize main object store and lookup tables, start server thread. */
165 /* Prototypes for object header */
166 unsigned int getNewOID(void);
167 unsigned int objSize(objheader_t *object);
168 /* end object header */
170 /* Prototypes for object store */
171 objstr_t *objstrCreate(unsigned int size); //size in bytes
172 void objstrDelete(objstr_t *store); //traverse and free entire list
173 void *objstrAlloc(objstr_t *store, unsigned int size); //size in bytes
174 /* end object store */
176 /* Prototypes for server portion */
178 void *dstmAccept(void *);
179 int readClientReq(trans_commit_data_t *, int);
180 int processClientReq(fixed_data_t *, trans_commit_data_t *,unsigned int *, char *, void *, int);
181 char handleTransReq(fixed_data_t *, trans_commit_data_t *, unsigned int *, char *, void *, int);
182 int decideCtrlMessage(fixed_data_t *, trans_commit_data_t *, int *, int *, int *, int *, int *, void *, unsigned int *, unsigned int *, unsigned int *, int);
183 int transCommitProcess(trans_commit_data_t *, int);
184 /* end server portion */
186 /* Prototypes for transactions */
187 void randomdelay(void);
188 transrecord_t *transStart();
189 objheader_t *transRead(transrecord_t *, unsigned int);
190 objheader_t *transCreateObj(transrecord_t *, unsigned short); //returns oid
191 int transCommit(transrecord_t *record); //return 0 if successful
192 void *transRequest(void *); //the C routine that the thread will execute when TRANS_REQUEST begins
193 void *handleLocalReq(void *); //the C routine that the local m/c thread will execute
194 int decideResponse(thread_data_array_t *);// Coordinator decides what response to send to the participant
195 char sendResponse(thread_data_array_t *, int); //Sends control message back to Participants
196 void *getRemoteObj(transrecord_t *, unsigned int, unsigned int);
197 int transAbortProcess(void *, unsigned int *, int, int, int);
198 int transComProcess(trans_commit_data_t *);
199 void prefetch(int, unsigned int *, short *, short*);
200 void *transPrefetch(void *);
201 void checkPrefetchTuples(prefetchqelem_t *);
202 void foundLocal(prefetchqelem_t *);
203 void makePreGroups(prefetchqelem_t *node);
204 void checkPreCache(prefetchqelem_t *, int *, int, int, unsigned int, int, int, int);
205 int transPrefetchProcess(transrecord_t *, int **, short);
206 void *sendPrefetchReq(void *);
207 /* end transactions */