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