more changes in rangeprefeches to handle prefetch requests at the server end
[IRC.git] / Robust / src / Runtime / DSTM / interface / prefetch.h
1 #ifndef _PREFETCH_H_
2 #define _PREFETCH_H_
3 #include "queue.h"
4 #include "dstm.h"
5
6 #define GET_STRIDE(x) ((x & 0x7000) >> 12)
7 #define GET_RANGE(x) (x & 0x0fff)
8 #define GET_STRIDEINC(x) ((x & 0x8000) >> 15)
9 #define GET_OID(x) ((int *) (x))
10 #define GET_NUM_OFFSETS(x) ((short *) (x + sizeof(unsigned int)))
11 #define GET_OFFSETS(x) ((short *) (x + sizeof(unsigned int) + sizeof(short)))
12
13 /****** Global structure **********/
14 typedef struct objOffsetPile {
15   unsigned int oid;
16   short numoffset;
17   short *offsets;
18   struct objOffsetPile *next;
19 } objOffsetPile_t;
20
21 typedef struct perMcPrefetchList {
22   unsigned int mid;
23   objOffsetPile_t *list;
24   struct perMcPrefetchList *next;
25 } perMcPrefetchList_t;
26
27 typedef struct proPrefetchQ {
28   perMcPrefetchList_t *front, *rear;
29   pthread_mutex_t qlock;
30   pthread_mutexattr_t qlockattr;
31   pthread_cond_t qcond;
32 } proPrefetchQ_t;
33
34 // Global Prefetch Processing Queue
35 proPrefetchQ_t prefetchQ;
36
37 /**** Prefetch Queue to be processed functions ******/
38 void proPrefetchQDealloc(perMcPrefetchList_t *);
39
40 /******** Process Queue Element functions ***********/
41 void rangePrefetch(unsigned int, short, short *);
42 void *transPrefetchNew();
43 perMcPrefetchList_t* checkIfLocal(char *ptr);
44 int isOidAvail(unsigned int oid);
45 int lookForObjs(int*, short *, int *, int *, int *, int *);
46 void insertPrefetch(int, unsigned int, short, short*, perMcPrefetchList_t **);
47
48 /******** Sending and Receiving Prefetches *******/
49 void sendRangePrefetchReq(perMcPrefetchList_t *, int sd);
50 int rangePrefetchReq(int acceptfd);
51 int getRangePrefetchResponse(int sd);
52
53 /************* Internal functions *******************/
54 int getsize(short *ptr, int n);
55
56 #endif