Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > Vthread_impls > Vthread_MC_shared_impl
diff 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 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/Vthread.h Thu Mar 01 13:20:51 2012 -0800 1.3 @@ -0,0 +1,259 @@ 1.4 +/* 1.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 1.6 + * Licensed under GNU General Public License version 2 1.7 + * 1.8 + * Author: seanhalle@yahoo.com 1.9 + * 1.10 + */ 1.11 + 1.12 +#ifndef _VPThread_H 1.13 +#define _VPThread_H 1.14 + 1.15 +#include "VMS_impl/VMS.h" 1.16 +#include "C_Libraries/Queue_impl/PrivateQueue.h" 1.17 +#include "C_Libraries/DynArray/DynArray.h" 1.18 + 1.19 + 1.20 +/*This header defines everything specific to the VPThread semantic plug-in 1.21 + */ 1.22 + 1.23 + 1.24 +//=========================================================================== 1.25 + //turn on the counter measurements of language overhead -- comment to turn off 1.26 +#define MEAS__TURN_ON_LANG_MEAS 1.27 + 1.28 +#define INIT_NUM_MUTEX 10000 1.29 +#define INIT_NUM_COND 10000 1.30 + 1.31 +#define NUM_STRUCS_IN_SEM_ENV 1000 1.32 +//=========================================================================== 1.33 + 1.34 +//=========================================================================== 1.35 +typedef struct _VPThreadSemReq VPThdSemReq; 1.36 +typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master 1.37 +//=========================================================================== 1.38 + 1.39 + 1.40 +/*WARNING: assembly hard-codes position of endInstrAddr as first field 1.41 + */ 1.42 +typedef struct 1.43 + { 1.44 + void *endInstrAddr; 1.45 + int32 hasBeenStarted; 1.46 + int32 hasFinished; 1.47 + PrivQueueStruc *waitQ; 1.48 + } 1.49 +VPThdSingleton; 1.50 + 1.51 +/*Semantic layer-specific data sent inside a request from lib called in app 1.52 + * to request handler called in MasterLoop 1.53 + */ 1.54 +enum VPThreadReqType 1.55 + { 1.56 + make_mutex = 1, 1.57 + mutex_lock, 1.58 + mutex_unlock, 1.59 + make_cond, 1.60 + cond_wait, 1.61 + cond_signal, 1.62 + make_procr, 1.63 + malloc_req, 1.64 + free_req, 1.65 + singleton_fn_start, 1.66 + singleton_fn_end, 1.67 + singleton_data_start, 1.68 + singleton_data_end, 1.69 + atomic, 1.70 + trans_start, 1.71 + trans_end 1.72 + }; 1.73 + 1.74 +struct _VPThreadSemReq 1.75 + { enum VPThreadReqType reqType; 1.76 + SlaveVP *requestingVP; 1.77 + int32 mutexIdx; 1.78 + int32 condIdx; 1.79 + 1.80 + void *initData; 1.81 + TopLevelFnPtr fnPtr; 1.82 + int32 coreToScheduleOnto; 1.83 + 1.84 + size_t sizeToMalloc; 1.85 + void *ptrToFree; 1.86 + 1.87 + int32 singletonID; 1.88 + VPThdSingleton **singletonPtrAddr; 1.89 + 1.90 + PtrToAtomicFn fnToExecInMaster; 1.91 + void *dataForFn; 1.92 + 1.93 + int32 transID; 1.94 + } 1.95 +/* VPThreadSemReq */; 1.96 + 1.97 + 1.98 +typedef struct 1.99 + { 1.100 + SlaveVP *VPCurrentlyExecuting; 1.101 + PrivQueueStruc *waitingVPQ; 1.102 + } 1.103 +VPThdTrans; 1.104 + 1.105 + 1.106 +typedef struct 1.107 + { 1.108 + int32 mutexIdx; 1.109 + SlaveVP *holderOfLock; 1.110 + PrivQueueStruc *waitingQueue; 1.111 + } 1.112 +VPThdMutex; 1.113 + 1.114 + 1.115 +typedef struct 1.116 + { 1.117 + int32 condIdx; 1.118 + PrivQueueStruc *waitingQueue; 1.119 + VPThdMutex *partnerMutex; 1.120 + } 1.121 +VPThdCond; 1.122 + 1.123 +typedef struct _TransListElem TransListElem; 1.124 +struct _TransListElem 1.125 + { 1.126 + int32 transID; 1.127 + TransListElem *nextTrans; 1.128 + }; 1.129 +//TransListElem 1.130 + 1.131 +typedef struct 1.132 + { 1.133 + int32 highestTransEntered; 1.134 + TransListElem *lastTransEntered; 1.135 + } 1.136 +VPThdSemData; 1.137 + 1.138 + 1.139 +typedef struct 1.140 + { 1.141 + //Standard stuff will be in most every semantic env 1.142 + PrivQueueStruc **readyVPQs; 1.143 + int32 numVirtVP; 1.144 + int32 nextCoreToGetNewVP; 1.145 + int32 primitiveStartTime; 1.146 + 1.147 + //Specific to this semantic layer 1.148 + VPThdMutex **mutexDynArray; 1.149 + PrivDynArrayInfo *mutexDynArrayInfo; 1.150 + 1.151 + VPThdCond **condDynArray; 1.152 + PrivDynArrayInfo *condDynArrayInfo; 1.153 + 1.154 + void *applicationGlobals; 1.155 + 1.156 + //fix limit on num with dynArray 1.157 + VPThdSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV]; 1.158 + 1.159 + VPThdTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV]; 1.160 + } 1.161 +VPThdSemEnv; 1.162 + 1.163 + 1.164 +//=========================================================================== 1.165 + 1.166 +inline void 1.167 +VPThread__create_seed_procr_and_do_work( TopLevelFnPtr fn, void *initData ); 1.168 + 1.169 +//======================= 1.170 + 1.171 +inline SlaveVP * 1.172 +VPThread__create_thread( TopLevelFnPtr fnPtr, void *initData, 1.173 + SlaveVP *creatingVP ); 1.174 + 1.175 +inline SlaveVP * 1.176 +VPThread__create_thread_with_affinity( TopLevelFnPtr fnPtr, void *initData, 1.177 + SlaveVP *creatingVP, int32 coreToScheduleOnto ); 1.178 + 1.179 +inline void 1.180 +VPThread__dissipate_thread( SlaveVP *procrToDissipate ); 1.181 + 1.182 +//======================= 1.183 +inline void 1.184 +VPThread__set_globals_to( void *globals ); 1.185 + 1.186 +inline void * 1.187 +VPThread__give_globals(); 1.188 + 1.189 +//======================= 1.190 +inline int32 1.191 +VPThread__make_mutex( SlaveVP *animVP ); 1.192 + 1.193 +inline void 1.194 +VPThread__mutex_lock( int32 mutexIdx, SlaveVP *acquiringVP ); 1.195 + 1.196 +inline void 1.197 +VPThread__mutex_unlock( int32 mutexIdx, SlaveVP *releasingVP ); 1.198 + 1.199 + 1.200 +//======================= 1.201 +inline int32 1.202 +VPThread__make_cond( int32 ownedMutexIdx, SlaveVP *animPr); 1.203 + 1.204 +inline void 1.205 +VPThread__cond_wait( int32 condIdx, SlaveVP *waitingPr); 1.206 + 1.207 +inline void * 1.208 +VPThread__cond_signal( int32 condIdx, SlaveVP *signallingVP ); 1.209 + 1.210 + 1.211 +//======================= 1.212 +void 1.213 +VPThread__start_fn_singleton( int32 singletonID, SlaveVP *animVP ); 1.214 + 1.215 +void 1.216 +VPThread__end_fn_singleton( int32 singletonID, SlaveVP *animVP ); 1.217 + 1.218 +void 1.219 +VPThread__start_data_singleton( VPThdSingleton **singeltonAddr, SlaveVP *animVP ); 1.220 + 1.221 +void 1.222 +VPThread__end_data_singleton( VPThdSingleton **singletonAddr, SlaveVP *animVP ); 1.223 + 1.224 +void 1.225 +VPThread__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster, 1.226 + void *data, SlaveVP *animVP ); 1.227 + 1.228 +void 1.229 +VPThread__start_transaction( int32 transactionID, SlaveVP *animVP ); 1.230 + 1.231 +void 1.232 +VPThread__end_transaction( int32 transactionID, SlaveVP *animVP ); 1.233 + 1.234 + 1.235 + 1.236 +//========================= Internal use only ============================= 1.237 +inline void 1.238 +VPThread__Request_Handler( SlaveVP *requestingVP, void *_semEnv ); 1.239 + 1.240 +inline SlaveVP * 1.241 +VPThread__schedule_virt_procr( void *_semEnv, int coreNum ); 1.242 + 1.243 +//======================= 1.244 +inline void 1.245 +VPThread__free_semantic_request( VPThdSemReq *semReq ); 1.246 + 1.247 +//======================= 1.248 + 1.249 +void * 1.250 +VPThread__malloc( size_t sizeToMalloc, SlaveVP *animVP ); 1.251 + 1.252 +void 1.253 +VPThread__init(); 1.254 + 1.255 +void 1.256 +VPThread__cleanup_after_shutdown(); 1.257 + 1.258 +void inline 1.259 +resume_procr( SlaveVP *procr, VPThdSemEnv *semEnv ); 1.260 + 1.261 +#endif /* _VPThread_H */ 1.262 +
