comparison VPThread.h @ 3:505d3c674ce8

Nov 20 PLDI final version -- working data singletons, meas hist macros in plugin
author Me
date Sat, 20 Nov 2010 08:39:58 +0100
parents e960a8d18f7c
children ce4ad44fcc23
comparison
equal deleted inserted replaced
2:b518dd4802ce 3:d0adf7722e97
28 //=========================================================================== 28 //===========================================================================
29 typedef struct _VPThreadSemReq VPThdSemReq; 29 typedef struct _VPThreadSemReq VPThdSemReq;
30 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master 30 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
31 //=========================================================================== 31 //===========================================================================
32 32
33
34 /*WARNING: assembly hard-codes position of endInstrAddr as first field
35 */
36 typedef struct
37 {
38 void *endInstrAddr;
39 int32 hasBeenStarted;
40 int32 hasFinished;
41 PrivQueueStruc *waitQ;
42 }
43 VPThdSingleton;
33 44
34 /*Semantic layer-specific data sent inside a request from lib called in app 45 /*Semantic layer-specific data sent inside a request from lib called in app
35 * to request handler called in MasterLoop 46 * to request handler called in MasterLoop
36 */ 47 */
37 enum VPThreadReqType 48 enum VPThreadReqType
43 cond_wait, 54 cond_wait,
44 cond_signal, 55 cond_signal,
45 make_procr, 56 make_procr,
46 malloc_req, 57 malloc_req,
47 free_req, 58 free_req,
48 singleton_start, 59 singleton_fn_start,
49 singleton_end, 60 singleton_fn_end,
61 singleton_data_start,
62 singleton_data_end,
50 atomic, 63 atomic,
51 trans_start, 64 trans_start,
52 trans_end 65 trans_end
53 }; 66 };
54 67
64 77
65 int32 sizeToMalloc; 78 int32 sizeToMalloc;
66 void *ptrToFree; 79 void *ptrToFree;
67 80
68 int32 singletonID; 81 int32 singletonID;
69 void *endJumpPt; 82 VPThdSingleton **singletonPtrAddr;
70 83
71 PtrToAtomicFn fnToExecInMaster; 84 PtrToAtomicFn fnToExecInMaster;
72 void *dataForFn; 85 void *dataForFn;
73 86
74 int32 transID; 87 int32 transID;
81 VirtProcr *VPCurrentlyExecuting; 94 VirtProcr *VPCurrentlyExecuting;
82 PrivQueueStruc *waitingVPQ; 95 PrivQueueStruc *waitingVPQ;
83 } 96 }
84 VPThdTrans; 97 VPThdTrans;
85 98
86 typedef struct
87 {
88 int32 hasBeenStarted;
89 int32 hasFinished;
90 void *endInstrAddr;
91 PrivQueueStruc *waitQ;
92 }
93 VPThdSingleton;
94 99
95 typedef struct 100 typedef struct
96 { 101 {
97 int32 mutexIdx; 102 int32 mutexIdx;
98 VirtProcr *holderOfLock; 103 VirtProcr *holderOfLock;
141 PrivDynArrayInfo *condDynArrayInfo; 146 PrivDynArrayInfo *condDynArrayInfo;
142 147
143 void *applicationGlobals; 148 void *applicationGlobals;
144 149
145 //fix limit on num with dynArray 150 //fix limit on num with dynArray
146 VPThdSingleton singletons[NUM_STRUCS_IN_SEM_ENV]; 151 VPThdSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
147 void *singletonEndInstrAddr;
148 152
149 VPThdTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV]; 153 VPThdTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
150 } 154 }
151 VPThdSemEnv; 155 VPThdSemEnv;
152 156
197 inline void * 201 inline void *
198 VPThread__cond_signal( int32 condIdx, VirtProcr *signallingPr ); 202 VPThread__cond_signal( int32 condIdx, VirtProcr *signallingPr );
199 203
200 204
201 //======================= 205 //=======================
202 206 void
203 void 207 VPThread__start_fn_singleton( int32 singletonID, VirtProcr *animPr );
204 VPThread__end_singleton( int32 singletonID, VirtProcr *animPr ); 208
205 209 void
206 inline void 210 VPThread__end_fn_singleton( int32 singletonID, VirtProcr *animPr );
207 VPThread__start_singleton( int32 singletonID, VirtProcr *animPr ); 211
212 void
213 VPThread__start_data_singleton( VPThdSingleton **singeltonAddr, VirtProcr *animPr );
214
215 void
216 VPThread__end_data_singleton( VPThdSingleton **singletonAddr, VirtProcr *animPr );
208 217
209 void 218 void
210 VPThread__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster, 219 VPThread__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
211 void *data, VirtProcr *animPr ); 220 void *data, VirtProcr *animPr );
212 221
235 VPThread__init(); 244 VPThread__init();
236 245
237 void 246 void
238 VPThread__cleanup_after_shutdown(); 247 VPThread__cleanup_after_shutdown();
239 248
249 void inline
250 resume_procr( VirtProcr *procr, VPThdSemEnv *semEnv );
251
240 #endif /* _VPThread_H */ 252 #endif /* _VPThread_H */
241 253