Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
changeset 37:c8d4f6d3c7d3 dev_expl_VP_and_DKU
hide animating VP and entry point
author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
---|---|
date | Wed, 15 May 2013 15:25:55 +0200 |
parents | 94911329b067 |
children | a951b38d2cfc |
files | VSs.c VSs.h |
diffstat | 2 files changed, 123 insertions(+), 89 deletions(-) [+] |
line diff
1.1 --- a/VSs.c Mon Apr 15 16:41:31 2013 +0200 1.2 +++ b/VSs.c Wed May 15 15:25:55 2013 +0200 1.3 @@ -183,9 +183,9 @@ 1.4 } 1.5 1.6 1.7 -void idle_fn(void* data, SlaveVP *animatingSlv){ 1.8 +void idle_fn(void* data){ 1.9 while(1){ 1.10 - VMS_int__suspend_slaveVP_and_send_req(animatingSlv); 1.11 + VMS_int__suspend_slaveVP_and_send_req(currVP); 1.12 } 1.13 } 1.14 1.15 @@ -487,10 +487,10 @@ 1.16 *It simply sends a dissipate request, which handles all the state cleanup. 1.17 */ 1.18 void 1.19 -VSs__end_thread( SlaveVP *thdToEnd ) 1.20 +VSs__end_thread() 1.21 { 1.22 1.23 - VMS_WL__send_dissipate_req( thdToEnd ); 1.24 + VMS_WL__send_dissipate_req( currVP ); 1.25 } 1.26 1.27 1.28 @@ -502,22 +502,22 @@ 1.29 /* 1.30 */ 1.31 void 1.32 -VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv) 1.33 +VSs__submit_task( VSsTaskType *taskType, void *args) 1.34 { VSsSemReq reqData; 1.35 1.36 reqData.reqType = submit_task; 1.37 1.38 reqData.taskType = taskType; 1.39 reqData.args = args; 1.40 - reqData.callingSlv = animSlv; 1.41 + reqData.callingSlv = currVP; 1.42 1.43 reqData.taskID = NULL; 1.44 1.45 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.46 + VMS_WL__send_sem_request( &reqData, currVP ); 1.47 } 1.48 1.49 int32 * 1.50 -VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv ) 1.51 +VSs__create_taskID_of_size( int32 numInts) 1.52 { int32 *taskID; 1.53 1.54 taskID = VMS_WL__malloc( sizeof(int32) + numInts * sizeof(int32) ); 1.55 @@ -526,8 +526,7 @@ 1.56 } 1.57 1.58 void 1.59 -VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID, 1.60 - SlaveVP *animSlv) 1.61 +VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID) 1.62 { VSsSemReq reqData; 1.63 1.64 reqData.reqType = submit_task; 1.65 @@ -535,9 +534,9 @@ 1.66 reqData.taskType = taskType; 1.67 reqData.args = args; 1.68 reqData.taskID = taskID; 1.69 - reqData.callingSlv = animSlv; 1.70 + reqData.callingSlv = currVP; 1.71 1.72 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.73 + VMS_WL__send_sem_request( &reqData, currVP ); 1.74 } 1.75 1.76 1.77 @@ -559,77 +558,78 @@ 1.78 *But, to stay compatible with all the other VMS languages, leave it in.. 1.79 */ 1.80 void 1.81 -VSs__end_task( SlaveVP *animSlv ) 1.82 +VSs__end_task() 1.83 { VSsSemReq reqData; 1.84 1.85 reqData.reqType = end_task; 1.86 - reqData.callingSlv = animSlv; 1.87 + reqData.callingSlv = currVP; 1.88 1.89 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.90 + VMS_WL__send_sem_request( &reqData, currVP ); 1.91 } 1.92 1.93 +void plugin__end_VP(){ 1.94 +VSs__end_task();} 1.95 1.96 void 1.97 -VSs__taskwait(SlaveVP *animSlv) 1.98 +VSs__taskwait() 1.99 { 1.100 VSsSemReq reqData; 1.101 1.102 reqData.reqType = taskwait; 1.103 - reqData.callingSlv = animSlv; 1.104 + reqData.callingSlv = currVP; 1.105 1.106 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.107 + VMS_WL__send_sem_request( &reqData, currVP ); 1.108 } 1.109 1.110 void 1.111 -VSs__taskwait_on(SlaveVP *animSlv,void* ptr){ 1.112 +VSs__taskwait_on(void* ptr){ 1.113 VSsSemReq reqData; 1.114 1.115 reqData.reqType = taskwait_on; 1.116 - reqData.callingSlv = animSlv; 1.117 + reqData.callingSlv = currVP; 1.118 1.119 reqData.args = ptr; 1.120 1.121 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.122 + VMS_WL__send_sem_request( &reqData, currVP ); 1.123 } 1.124 1.125 void 1.126 -VSs__start_critical(SlaveVP *animSlv,int32 name){ 1.127 +VSs__start_critical(int32 name){ 1.128 VSsSemReq reqData; 1.129 1.130 reqData.reqType = critical_start; 1.131 - reqData.callingSlv = animSlv; 1.132 + reqData.callingSlv = currVP; 1.133 1.134 reqData.criticalID = name; 1.135 1.136 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.137 + VMS_WL__send_sem_request( &reqData, currVP ); 1.138 } 1.139 1.140 void 1.141 -VSs__end_critical(SlaveVP *animSlv,int32 name){ 1.142 +VSs__end_critical(int32 name){ 1.143 VSsSemReq reqData; 1.144 1.145 reqData.reqType = critical_end; 1.146 - reqData.callingSlv = animSlv; 1.147 + reqData.callingSlv = currVP; 1.148 1.149 reqData.criticalID = name; 1.150 1.151 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.152 + VMS_WL__send_sem_request( &reqData, currVP ); 1.153 } 1.154 1.155 //========================== send and receive ============================ 1.156 // 1.157 1.158 int32 * 1.159 -VSs__give_self_taskID( SlaveVP *animSlv ) 1.160 +VSs__give_self_taskID() 1.161 { 1.162 - return ((VSsSemData*)animSlv->semanticData)->taskStub->taskID; 1.163 + return ((VSsSemData*)currVP->semanticData)->taskStub->taskID; 1.164 } 1.165 1.166 //================================ send =================================== 1.167 1.168 void 1.169 -VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID, 1.170 - SlaveVP *senderSlv ) 1.171 +VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID) 1.172 { VSsSemReq reqData; 1.173 1.174 reqData.reqType = send_type_to; 1.175 @@ -637,17 +637,17 @@ 1.176 reqData.msg = msg; 1.177 reqData.msgType = type; 1.178 reqData.receiverID = receiverID; 1.179 - reqData.senderSlv = senderSlv; 1.180 + reqData.senderSlv = currVP; 1.181 1.182 reqData.nextReqInHashEntry = NULL; 1.183 1.184 - VMS_WL__send_sem_request( &reqData, senderSlv ); 1.185 + VMS_WL__send_sem_request( &reqData, currVP ); 1.186 1.187 //When come back from suspend, no longer own data reachable from msg 1.188 } 1.189 1.190 void 1.191 -VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv ) 1.192 +VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID) 1.193 { VSsSemReq reqData; 1.194 1.195 reqData.reqType = send_from_to; 1.196 @@ -655,11 +655,11 @@ 1.197 reqData.msg = msg; 1.198 reqData.senderID = senderID; 1.199 reqData.receiverID = receiverID; 1.200 - reqData.senderSlv = senderSlv; 1.201 + reqData.senderSlv = currVP; 1.202 1.203 reqData.nextReqInHashEntry = NULL; 1.204 1.205 - VMS_WL__send_sem_request( &reqData, senderSlv ); 1.206 + VMS_WL__send_sem_request( &reqData, currVP ); 1.207 } 1.208 1.209 1.210 @@ -672,7 +672,7 @@ 1.211 * messages. 1.212 */ 1.213 void * 1.214 -VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv ) 1.215 +VSs__receive_type_to( const int32 type, int32* receiverID ) 1.216 { DEBUG__printf1(dbgRqstHdlr,"WL: receive type to %d",receiverID[1] ); 1.217 VSsSemReq reqData; 1.218 1.219 @@ -680,13 +680,13 @@ 1.220 1.221 reqData.msgType = type; 1.222 reqData.receiverID = receiverID; 1.223 - reqData.receiverSlv = receiverSlv; 1.224 + reqData.receiverSlv = currVP; 1.225 1.226 reqData.nextReqInHashEntry = NULL; 1.227 1.228 - VMS_WL__send_sem_request( &reqData, receiverSlv ); 1.229 + VMS_WL__send_sem_request( &reqData, currVP ); 1.230 1.231 - return receiverSlv->dataRetFromReq; 1.232 + return currVP->dataRetFromReq; 1.233 } 1.234 1.235 1.236 @@ -696,7 +696,7 @@ 1.237 * between sender and receiver. 1.238 */ 1.239 void * 1.240 -VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv ) 1.241 +VSs__receive_from_to( int32 *senderID, int32 *receiverID) 1.242 { 1.243 VSsSemReq reqData; 1.244 1.245 @@ -704,14 +704,14 @@ 1.246 1.247 reqData.senderID = senderID; 1.248 reqData.receiverID = receiverID; 1.249 - reqData.receiverSlv = receiverSlv; 1.250 + reqData.receiverSlv = currVP; 1.251 1.252 reqData.nextReqInHashEntry = NULL; 1.253 DEBUG__printf2(dbgRqstHdlr,"WL: receive from %d to: %d", reqData.senderID[1], reqData.receiverID[1]); 1.254 1.255 - VMS_WL__send_sem_request( &reqData, receiverSlv ); 1.256 + VMS_WL__send_sem_request( &reqData, currVP ); 1.257 1.258 - return receiverSlv->dataRetFromReq; 1.259 + return currVP->dataRetFromReq; 1.260 } 1.261 1.262 1.263 @@ -737,7 +737,7 @@ 1.264 * semantic environment. 1.265 */ 1.266 void 1.267 -VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv ) 1.268 +VSs__start_fn_singleton( int32 singletonID) 1.269 { 1.270 VSsSemReq reqData; 1.271 1.272 @@ -745,10 +745,10 @@ 1.273 reqData.reqType = singleton_fn_start; 1.274 reqData.singletonID = singletonID; 1.275 1.276 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.277 - if( animSlv->dataRetFromReq ) //will be 0 or addr of label in end singleton 1.278 + VMS_WL__send_sem_request( &reqData, currVP ); 1.279 + if( currVP->dataRetFromReq ) //will be 0 or addr of label in end singleton 1.280 { 1.281 - VSsSemEnv *semEnv = VMS_int__give_sem_env_for( animSlv ); 1.282 + VSsSemEnv *semEnv = VMS_int__give_sem_env_for( currVP ); 1.283 asm_write_ret_from_singleton(&(semEnv->fnSingletons[ singletonID])); 1.284 } 1.285 } 1.286 @@ -758,7 +758,7 @@ 1.287 * location. 1.288 */ 1.289 void 1.290 -VSs__start_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv ) 1.291 +VSs__start_data_singleton( VSsSingleton **singletonAddr ) 1.292 { 1.293 VSsSemReq reqData; 1.294 1.295 @@ -768,8 +768,8 @@ 1.296 reqData.reqType = singleton_data_start; 1.297 reqData.singletonPtrAddr = singletonAddr; 1.298 1.299 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.300 - if( animSlv->dataRetFromReq ) //either 0 or end singleton's return addr 1.301 + VMS_WL__send_sem_request( &reqData, currVP ); 1.302 + if( currVP->dataRetFromReq ) //either 0 or end singleton's return addr 1.303 { //Assembly code changes the return addr on the stack to the one 1.304 // saved into the singleton by the end-singleton-fn 1.305 //The return addr is at 0x4(%%ebp) 1.306 @@ -787,26 +787,26 @@ 1.307 * inside is shared by all invocations of a given singleton ID. 1.308 */ 1.309 void 1.310 -VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv ) 1.311 +VSs__end_fn_singleton( int32 singletonID ) 1.312 { 1.313 VSsSemReq reqData; 1.314 1.315 //don't need this addr until after at least one singleton has reached 1.316 // this function 1.317 - VSsSemEnv *semEnv = VMS_int__give_sem_env_for( animSlv ); 1.318 + VSsSemEnv *semEnv = VMS_int__give_sem_env_for( currVP ); 1.319 asm_write_ret_from_singleton(&(semEnv->fnSingletons[ singletonID])); 1.320 1.321 reqData.reqType = singleton_fn_end; 1.322 reqData.singletonID = singletonID; 1.323 1.324 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.325 + VMS_WL__send_sem_request( &reqData, currVP ); 1.326 1.327 //EndSingletonInstrAddr: 1.328 return; 1.329 } 1.330 1.331 void 1.332 -VSs__end_data_singleton( VSsSingleton **singletonPtrAddr, SlaveVP *animSlv ) 1.333 +VSs__end_data_singleton( VSsSingleton **singletonPtrAddr ) 1.334 { 1.335 VSsSemReq reqData; 1.336 1.337 @@ -824,7 +824,7 @@ 1.338 reqData.reqType = singleton_data_end; 1.339 reqData.singletonPtrAddr = singletonPtrAddr; 1.340 1.341 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.342 + VMS_WL__send_sem_request( &reqData, currVP ); 1.343 } 1.344 1.345 /*This executes the function in the masterVP, so it executes in isolation 1.346 @@ -839,7 +839,7 @@ 1.347 */ 1.348 void 1.349 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster, 1.350 - void *data, SlaveVP *animSlv ) 1.351 + void *data ) 1.352 { 1.353 VSsSemReq reqData; 1.354 1.355 @@ -848,7 +848,7 @@ 1.356 reqData.fnToExecInMaster = ptrToFnToExecInMaster; 1.357 reqData.dataForFn = data; 1.358 1.359 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.360 + VMS_WL__send_sem_request( &reqData, currVP ); 1.361 } 1.362 1.363 1.364 @@ -866,16 +866,16 @@ 1.365 *If NULL, then write requesting into the field and resume. 1.366 */ 1.367 void 1.368 -VSs__start_transaction( int32 transactionID, SlaveVP *animSlv ) 1.369 +VSs__start_transaction( int32 transactionID ) 1.370 { 1.371 VSsSemReq reqData; 1.372 1.373 // 1.374 - reqData.callingSlv = animSlv; 1.375 + reqData.callingSlv = currVP; 1.376 reqData.reqType = trans_start; 1.377 reqData.transID = transactionID; 1.378 1.379 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.380 + VMS_WL__send_sem_request( &reqData, currVP ); 1.381 } 1.382 1.383 /*This suspends to the master, then uses transactionID as index into an 1.384 @@ -888,16 +888,16 @@ 1.385 * resumes both. 1.386 */ 1.387 void 1.388 -VSs__end_transaction( int32 transactionID, SlaveVP *animSlv ) 1.389 +VSs__end_transaction( int32 transactionID ) 1.390 { 1.391 VSsSemReq reqData; 1.392 1.393 // 1.394 - reqData.callingSlv = animSlv; 1.395 + reqData.callingSlv = currVP; 1.396 reqData.reqType = trans_end; 1.397 reqData.transID = transactionID; 1.398 1.399 - VMS_WL__send_sem_request( &reqData, animSlv ); 1.400 + VMS_WL__send_sem_request( &reqData, currVP ); 1.401 } 1.402 1.403 //======================== Internal ================================== 1.404 @@ -941,3 +941,20 @@ 1.405 return creatingSlv->dataRetFromReq; 1.406 } 1.407 1.408 +int __main_ret; 1.409 + 1.410 +void __entry_point(void* _args) { 1.411 + __main_args* args = (__main_args*) _args; 1.412 + __main_ret = __program_main(args->argc, args->argv); 1.413 + VSs__end_thread(); 1.414 +} 1.415 + 1.416 +#undef main 1.417 + 1.418 +int main(int argc, char** argv) { 1.419 + __main_args args; 1.420 + args.argc = argc; 1.421 + args.argv = argv; 1.422 + VSs__create_seed_slave_and_do_work(__entry_point, (void*) &args); 1.423 + return __main_ret; 1.424 +} 1.425 \ No newline at end of file
2.1 --- a/VSs.h Mon Apr 15 16:41:31 2013 +0200 2.2 +++ b/VSs.h Wed May 15 15:25:55 2013 +0200 2.3 @@ -39,7 +39,7 @@ 2.4 /*This header defines everything specific to the VSs semantic plug-in 2.5 */ 2.6 typedef struct _VSsSemReq VSsSemReq; 2.7 -typedef void (*VSsTaskFnPtr ) ( void *, SlaveVP *); 2.8 +typedef void (*VSsTaskFnPtr ) ( void * ); 2.9 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master 2.10 //=========================================================================== 2.11 2.12 @@ -318,7 +318,7 @@ 2.13 SlaveVP *creatingThd ); 2.14 2.15 void 2.16 -VSs__end_thread( SlaveVP *thdToEnd ); 2.17 +VSs__end_thread(); 2.18 2.19 //======================= 2.20 2.21 @@ -329,69 +329,67 @@ 2.22 2.23 //======================= 2.24 void 2.25 -VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv); 2.26 +VSs__submit_task( VSsTaskType *taskType, void *args); 2.27 2.28 int32 * 2.29 -VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv ); 2.30 +VSs__create_taskID_of_size( int32 numInts); 2.31 2.32 void 2.33 -VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID, 2.34 - SlaveVP *animSlv); 2.35 +VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID); 2.36 2.37 void 2.38 -VSs__end_task( SlaveVP *animSlv ); 2.39 +VSs__end_task(); 2.40 2.41 //========================= 2.42 void 2.43 -VSs__taskwait(SlaveVP *animSlv); 2.44 +VSs__taskwait(); 2.45 2.46 void 2.47 -VSs__taskwait_on(SlaveVP *animSlv,void* ptr); 2.48 +VSs__taskwait_on(void* ptr); 2.49 2.50 void 2.51 -VSs__start_critical(SlaveVP *animSlv,int32 name); 2.52 +VSs__start_critical(int32 name); 2.53 2.54 void 2.55 -VSs__end_critical(SlaveVP *animSlv,int32 name); 2.56 +VSs__end_critical(int32 name); 2.57 2.58 int32 * 2.59 -VSs__give_self_taskID( SlaveVP *animSlv ); 2.60 +VSs__give_self_taskID(); 2.61 2.62 void 2.63 -VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID, 2.64 - SlaveVP *senderSlv ); 2.65 +VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID); 2.66 2.67 void 2.68 -VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv ); 2.69 +VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID); 2.70 2.71 void * 2.72 -VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv ); 2.73 +VSs__receive_type_to( const int32 type, int32* receiverID ); 2.74 2.75 void * 2.76 -VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv ); 2.77 +VSs__receive_from_to( int32 *senderID, int32 *receiverID ); 2.78 2.79 //======================= Concurrency Stuff ====================== 2.80 void 2.81 -VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv ); 2.82 +VSs__start_fn_singleton( int32 singletonID ); 2.83 2.84 void 2.85 -VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv ); 2.86 +VSs__end_fn_singleton( int32 singletonID ); 2.87 2.88 void 2.89 -VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv ); 2.90 +VSs__start_data_singleton( VSsSingleton **singeltonAddr ); 2.91 2.92 void 2.93 -VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv ); 2.94 +VSs__end_data_singleton( VSsSingleton **singletonAddr ); 2.95 2.96 void 2.97 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster, 2.98 - void *data, SlaveVP *animSlv ); 2.99 + void *data ); 2.100 2.101 void 2.102 -VSs__start_transaction( int32 transactionID, SlaveVP *animSlv ); 2.103 +VSs__start_transaction( int32 transactionID ); 2.104 2.105 void 2.106 -VSs__end_transaction( int32 transactionID, SlaveVP *animSlv ); 2.107 +VSs__end_transaction( int32 transactionID ); 2.108 2.109 2.110 //========================= Internal use only ============================= 2.111 @@ -418,7 +416,7 @@ 2.112 SlaveVP *creatingSlv, int32 coreToAssignOnto); 2.113 2.114 void 2.115 -idle_fn(void* data, SlaveVP *animatingSlv); 2.116 +idle_fn(void* data); 2.117 2.118 void 2.119 resume_slaveVP(SlaveVP *slave, VSsSemEnv *semEnv); 2.120 @@ -427,5 +425,24 @@ 2.121 #include "Measurement/VSs_Measurement.h" 2.122 2.123 //=========================================================================== 2.124 + 2.125 +/* Hide entry point trick */ 2.126 + 2.127 +typedef struct { 2.128 + int argc; 2.129 + char** argv; 2.130 +} __main_args; 2.131 + 2.132 +extern int __main_ret; 2.133 + 2.134 +int __program_main(int argc, char** argv); 2.135 + 2.136 +void __entry_point(void* _args); 2.137 + 2.138 +int main(int argc, char** argv); 2.139 + 2.140 + 2.141 +#define main __program_main 2.142 + 2.143 #endif /* _VSs_H */ 2.144