Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > Vthread_impls > Vthread_MC_shared_impl
comparison Vthread.h @ 28:b3a881f25c5a
Nearly compiles with in-process common_ancestor vers of VMS
| author | Some Random Person <seanhalle@yahoo.com> |
|---|---|
| date | Sun, 04 Mar 2012 14:29:42 -0800 |
| parents | e5d4d5871ac9 |
| children | b94dc57e4455 |
comparison
equal
deleted
inserted
replaced
| 0:3e05365863a0 | 1:3d63ec35bee9 |
|---|---|
| 4 * | 4 * |
| 5 * Author: seanhalle@yahoo.com | 5 * Author: seanhalle@yahoo.com |
| 6 * | 6 * |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef _VPThread_H | 9 #ifndef _Vthread_H |
| 10 #define _VPThread_H | 10 #define _Vthread_H |
| 11 | |
| 12 #define _LANG_NAME_ "Vthread" | |
| 11 | 13 |
| 12 #include "VMS_impl/VMS.h" | 14 #include "VMS_impl/VMS.h" |
| 13 #include "C_Libraries/Queue_impl/PrivateQueue.h" | 15 #include "C_Libraries/Queue_impl/PrivateQueue.h" |
| 14 #include "C_Libraries/DynArray/DynArray.h" | 16 #include "C_Libraries/DynArray/DynArray.h" |
| 15 | 17 |
| 16 | 18 |
| 17 /*This header defines everything specific to the VPThread semantic plug-in | 19 /*This header defines everything specific to the Vthread semantic plug-in |
| 18 */ | 20 */ |
| 19 | 21 |
| 20 | 22 |
| 21 //=========================================================================== | 23 //=========================================================================== |
| 22 //turn on the counter measurements of language overhead -- comment to turn off | 24 //turn on the counter measurements of language overhead -- comment to turn off |
| 23 #define MEAS__TURN_ON_LANG_MEAS | 25 #define MEAS__TURN_ON_LANG_MEAS |
| 26 #include "Vthread_Overhead_Meas.h" | |
| 24 | 27 |
| 25 #define INIT_NUM_MUTEX 10000 | 28 #define INIT_NUM_MUTEX 10000 |
| 26 #define INIT_NUM_COND 10000 | 29 #define INIT_NUM_COND 10000 |
| 27 | 30 |
| 28 #define NUM_STRUCS_IN_SEM_ENV 1000 | 31 #define NUM_STRUCS_IN_SEM_ENV 1000 |
| 29 //=========================================================================== | 32 //=========================================================================== |
| 30 | 33 |
| 31 //=========================================================================== | 34 //=========================================================================== |
| 32 typedef struct _VPThreadSemReq VPThdSemReq; | 35 typedef struct _VthreadSemReq VthdSemReq; |
| 33 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master | 36 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master |
| 34 //=========================================================================== | 37 //=========================================================================== |
| 35 | 38 |
| 36 | 39 |
| 37 /*WARNING: assembly hard-codes position of endInstrAddr as first field | 40 /*WARNING: assembly hard-codes position of endInstrAddr as first field |
| 38 */ | 41 */ |
| 39 typedef struct | 42 typedef struct |
| 40 { | 43 { |
| 41 void *endInstrAddr; | 44 void *savedRetAddr; |
| 42 int32 hasBeenStarted; | 45 int32 hasBeenStarted; |
| 43 int32 hasFinished; | 46 int32 hasFinished; |
| 44 PrivQueueStruc *waitQ; | 47 PrivQueueStruc *waitQ; |
| 45 } | 48 } |
| 46 VPThdSingleton; | 49 VthdSingleton; |
| 47 | 50 |
| 48 /*Semantic layer-specific data sent inside a request from lib called in app | 51 /*Semantic layer-specific data sent inside a request from lib called in app |
| 49 * to request handler called in MasterLoop | 52 * to request handler called in MasterLoop |
| 50 */ | 53 */ |
| 51 enum VPThreadReqType | 54 enum VthreadReqType |
| 52 { | 55 { |
| 53 make_mutex = 1, | 56 make_mutex = 1, |
| 54 mutex_lock, | 57 mutex_lock, |
| 55 mutex_unlock, | 58 mutex_unlock, |
| 56 make_cond, | 59 make_cond, |
| 57 cond_wait, | 60 cond_wait, |
| 58 cond_signal, | 61 cond_signal, |
| 59 make_procr, | 62 make_slaveVP, |
| 60 malloc_req, | 63 malloc_req, |
| 61 free_req, | 64 free_req, |
| 62 singleton_fn_start, | 65 singleton_fn_start, |
| 63 singleton_fn_end, | 66 singleton_fn_end, |
| 64 singleton_data_start, | 67 singleton_data_start, |
| 66 atomic, | 69 atomic, |
| 67 trans_start, | 70 trans_start, |
| 68 trans_end | 71 trans_end |
| 69 }; | 72 }; |
| 70 | 73 |
| 71 struct _VPThreadSemReq | 74 struct _VthreadSemReq |
| 72 { enum VPThreadReqType reqType; | 75 { enum VthreadReqType reqType; |
| 73 SlaveVP *requestingVP; | 76 SlaveVP *requestingSlv; |
| 74 int32 mutexIdx; | 77 int32 mutexIdx; |
| 75 int32 condIdx; | 78 int32 condIdx; |
| 76 | 79 |
| 77 void *initData; | 80 void *initData; |
| 78 TopLevelFnPtr fnPtr; | 81 TopLevelFnPtr fnPtr; |
| 80 | 83 |
| 81 size_t sizeToMalloc; | 84 size_t sizeToMalloc; |
| 82 void *ptrToFree; | 85 void *ptrToFree; |
| 83 | 86 |
| 84 int32 singletonID; | 87 int32 singletonID; |
| 85 VPThdSingleton **singletonPtrAddr; | 88 VthdSingleton *singleton; |
| 86 | 89 |
| 87 PtrToAtomicFn fnToExecInMaster; | 90 PtrToAtomicFn fnToExecInMaster; |
| 88 void *dataForFn; | 91 void *dataForFn; |
| 89 | 92 |
| 90 int32 transID; | 93 int32 transID; |
| 91 } | 94 } |
| 92 /* VPThreadSemReq */; | 95 /* VthreadSemReq */; |
| 93 | 96 |
| 94 | 97 |
| 95 typedef struct | 98 typedef struct |
| 96 { | 99 { |
| 97 SlaveVP *VPCurrentlyExecuting; | 100 SlaveVP *SlvCurrentlyExecuting; |
| 98 PrivQueueStruc *waitingVPQ; | 101 PrivQueueStruc *waitingSlvQ; |
| 99 } | 102 } |
| 100 VPThdTrans; | 103 VthdTrans; |
| 101 | 104 |
| 102 | 105 |
| 103 typedef struct | 106 typedef struct |
| 104 { | 107 { |
| 105 int32 mutexIdx; | 108 int32 mutexIdx; |
| 106 SlaveVP *holderOfLock; | 109 SlaveVP *holderOfLock; |
| 107 PrivQueueStruc *waitingQueue; | 110 PrivQueueStruc *waitingQueue; |
| 108 } | 111 } |
| 109 VPThdMutex; | 112 VthdMutex; |
| 110 | 113 |
| 111 | 114 |
| 112 typedef struct | 115 typedef struct |
| 113 { | 116 { |
| 114 int32 condIdx; | 117 int32 condIdx; |
| 115 PrivQueueStruc *waitingQueue; | 118 PrivQueueStruc *waitingQueue; |
| 116 VPThdMutex *partnerMutex; | 119 VthdMutex *partnerMutex; |
| 117 } | 120 } |
| 118 VPThdCond; | 121 VthdCond; |
| 119 | 122 |
| 120 typedef struct _TransListElem TransListElem; | 123 typedef struct _TransListElem TransListElem; |
| 121 struct _TransListElem | 124 struct _TransListElem |
| 122 { | 125 { |
| 123 int32 transID; | 126 int32 transID; |
| 128 typedef struct | 131 typedef struct |
| 129 { | 132 { |
| 130 int32 highestTransEntered; | 133 int32 highestTransEntered; |
| 131 TransListElem *lastTransEntered; | 134 TransListElem *lastTransEntered; |
| 132 } | 135 } |
| 133 VPThdSemData; | 136 VthdSemData; |
| 134 | 137 |
| 135 | 138 |
| 136 typedef struct | 139 typedef struct |
| 137 { | 140 { |
| 138 //Standard stuff will be in most every semantic env | 141 //Standard stuff will be in most every semantic env |
| 139 PrivQueueStruc **readyVPQs; | 142 PrivQueueStruc **readySlvQs; |
| 140 int32 numVirtVP; | 143 int32 nextCoreToGetNewSlv; |
| 141 int32 nextCoreToGetNewVP; | |
| 142 int32 primitiveStartTime; | 144 int32 primitiveStartTime; |
| 143 | 145 |
| 144 //Specific to this semantic layer | 146 //Specific to this semantic layer |
| 145 VPThdMutex **mutexDynArray; | 147 VthdMutex **mutexDynArray; |
| 146 PrivDynArrayInfo *mutexDynArrayInfo; | 148 PrivDynArrayInfo *mutexDynArrayInfo; |
| 147 | 149 |
| 148 VPThdCond **condDynArray; | 150 VthdCond **condDynArray; |
| 149 PrivDynArrayInfo *condDynArrayInfo; | 151 PrivDynArrayInfo *condDynArrayInfo; |
| 150 | 152 |
| 151 void *applicationGlobals; | 153 void *applicationGlobals; |
| 152 | 154 |
| 153 //fix limit on num with dynArray | 155 //fix limit on num with dynArray |
| 154 VPThdSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV]; | 156 VthdSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV]; |
| 155 | 157 |
| 156 VPThdTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV]; | 158 VthdTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV]; |
| 157 } | 159 } |
| 158 VPThdSemEnv; | 160 VthdSemEnv; |
| 159 | 161 |
| 160 | 162 |
| 161 //=========================================================================== | 163 //=========================================================================== |
| 162 | 164 |
| 163 inline void | 165 inline void |
| 164 VPThread__create_seed_procr_and_do_work( TopLevelFnPtr fn, void *initData ); | 166 Vthread__create_seed_slaveVP_and_do_work( TopLevelFnPtr fn, void *initData ); |
| 165 | 167 |
| 166 //======================= | 168 //======================= |
| 167 | 169 |
| 168 inline SlaveVP * | 170 inline SlaveVP * |
| 169 VPThread__create_thread( TopLevelFnPtr fnPtr, void *initData, | 171 Vthread__create_thread( TopLevelFnPtr fnPtr, void *initData, |
| 170 SlaveVP *creatingVP ); | 172 SlaveVP *creatingSlv ); |
| 171 | 173 |
| 172 inline SlaveVP * | 174 inline SlaveVP * |
| 173 VPThread__create_thread_with_affinity( TopLevelFnPtr fnPtr, void *initData, | 175 Vthread__create_thread_with_affinity( TopLevelFnPtr fnPtr, void *initData, |
| 174 SlaveVP *creatingVP, int32 coreToScheduleOnto ); | 176 SlaveVP *creatingSlv, int32 coreToScheduleOnto ); |
| 175 | 177 |
| 176 inline void | 178 inline void |
| 177 VPThread__dissipate_thread( SlaveVP *procrToDissipate ); | 179 Vthread__dissipate_thread( SlaveVP *procrToDissipate ); |
| 178 | 180 |
| 179 //======================= | 181 //======================= |
| 180 inline void | 182 inline void |
| 181 VPThread__set_globals_to( void *globals ); | 183 Vthread__set_globals_to( void *globals ); |
| 182 | 184 |
| 183 inline void * | 185 inline void * |
| 184 VPThread__give_globals(); | 186 Vthread__give_globals(); |
| 185 | 187 |
| 186 //======================= | 188 //======================= |
| 187 inline int32 | 189 inline int32 |
| 188 VPThread__make_mutex( SlaveVP *animVP ); | 190 Vthread__make_mutex( SlaveVP *animSlv ); |
| 189 | 191 |
| 190 inline void | 192 inline void |
| 191 VPThread__mutex_lock( int32 mutexIdx, SlaveVP *acquiringVP ); | 193 Vthread__mutex_lock( int32 mutexIdx, SlaveVP *acquiringSlv ); |
| 192 | 194 |
| 193 inline void | 195 inline void |
| 194 VPThread__mutex_unlock( int32 mutexIdx, SlaveVP *releasingVP ); | 196 Vthread__mutex_unlock( int32 mutexIdx, SlaveVP *releasingSlv ); |
| 195 | 197 |
| 196 | 198 |
| 197 //======================= | 199 //======================= |
| 198 inline int32 | 200 inline int32 |
| 199 VPThread__make_cond( int32 ownedMutexIdx, SlaveVP *animPr); | 201 Vthread__make_cond( int32 ownedMutexIdx, SlaveVP *animSlv); |
| 200 | 202 |
| 201 inline void | 203 inline void |
| 202 VPThread__cond_wait( int32 condIdx, SlaveVP *waitingPr); | 204 Vthread__cond_wait( int32 condIdx, SlaveVP *waitingSlv); |
| 203 | 205 |
| 204 inline void * | 206 inline void * |
| 205 VPThread__cond_signal( int32 condIdx, SlaveVP *signallingVP ); | 207 Vthread__cond_signal( int32 condIdx, SlaveVP *signallingSlv ); |
| 206 | 208 |
| 207 | 209 |
| 208 //======================= | 210 //======================= |
| 209 void | 211 void |
| 210 VPThread__start_fn_singleton( int32 singletonID, SlaveVP *animVP ); | 212 Vthread__start_fn_singleton( int32 singletonID, SlaveVP *animSlv ); |
| 211 | 213 |
| 212 void | 214 void |
| 213 VPThread__end_fn_singleton( int32 singletonID, SlaveVP *animVP ); | 215 Vthread__end_fn_singleton( int32 singletonID, SlaveVP *animSlv ); |
| 214 | 216 |
| 215 void | 217 void |
| 216 VPThread__start_data_singleton( VPThdSingleton **singeltonAddr, SlaveVP *animVP ); | 218 Vthread__start_data_singleton( VthdSingleton *singelton, SlaveVP *animSlv ); |
| 217 | 219 |
| 218 void | 220 void |
| 219 VPThread__end_data_singleton( VPThdSingleton **singletonAddr, SlaveVP *animVP ); | 221 Vthread__end_data_singleton( VthdSingleton *singleton, SlaveVP *animSlv ); |
| 220 | 222 |
| 221 void | 223 void |
| 222 VPThread__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster, | 224 Vthread__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster, |
| 223 void *data, SlaveVP *animVP ); | 225 void *data, SlaveVP *animSlv ); |
| 224 | 226 |
| 225 void | 227 void |
| 226 VPThread__start_transaction( int32 transactionID, SlaveVP *animVP ); | 228 Vthread__start_transaction( int32 transactionID, SlaveVP *animSlv ); |
| 227 | 229 |
| 228 void | 230 void |
| 229 VPThread__end_transaction( int32 transactionID, SlaveVP *animVP ); | 231 Vthread__end_transaction( int32 transactionID, SlaveVP *animSlv ); |
| 230 | 232 |
| 231 | 233 |
| 232 | 234 |
| 233 //========================= Internal use only ============================= | 235 //========================= Internal use only ============================= |
| 234 inline void | 236 inline void |
| 235 VPThread__Request_Handler( SlaveVP *requestingVP, void *_semEnv ); | 237 Vthread__Request_Handler( SlaveVP *requestingSlv, void *_semEnv ); |
| 236 | 238 |
| 237 inline SlaveVP * | 239 inline SlaveVP * |
| 238 VPThread__schedule_virt_procr( void *_semEnv, int coreNum ); | 240 Vthread__schedule_slaveVP( void *_semEnv, int coreNum ); |
| 239 | 241 |
| 240 //======================= | 242 //======================= |
| 241 inline void | 243 inline void |
| 242 VPThread__free_semantic_request( VPThdSemReq *semReq ); | 244 Vthread__free_semantic_request( VthdSemReq *semReq ); |
| 243 | 245 |
| 244 //======================= | 246 //======================= |
| 245 | 247 |
| 246 void * | 248 void * |
| 247 VPThread__malloc( size_t sizeToMalloc, SlaveVP *animVP ); | 249 Vthread__malloc( size_t sizeToMalloc, SlaveVP *animSlv ); |
| 248 | 250 |
| 249 void | 251 void |
| 250 VPThread__init(); | 252 Vthread__init(); |
| 251 | 253 |
| 252 void | 254 void |
| 253 VPThread__cleanup_after_shutdown(); | 255 Vthread__cleanup_after_shutdown(); |
| 254 | 256 |
| 255 void inline | 257 void inline |
| 256 resume_procr( SlaveVP *procr, VPThdSemEnv *semEnv ); | 258 resume_slaveVP( SlaveVP *procr, VthdSemEnv *semEnv ); |
| 257 | 259 |
| 258 #endif /* _VPThread_H */ | 260 #endif /* _Vthread_H */ |
| 259 | 261 |
