Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
diff VSs.c @ 4:13af59ed7ea5
Works -- with send-receive plus normal dependencies
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Thu, 14 Jun 2012 18:44:47 -0700 |
| parents | 468b8638ff92 |
| children | 8188c5b4bfd7 |
line diff
1.1 --- a/VSs.c Wed Jun 06 17:55:36 2012 -0700 1.2 +++ b/VSs.c Thu Jun 14 18:44:47 2012 -0700 1.3 @@ -226,6 +226,7 @@ 1.4 semanticEnv->numSlaveVP = 0; 1.5 1.6 semanticEnv->argPtrHashTbl = makeHashTable32( 16, &VMS_int__free ); 1.7 + semanticEnv->commHashTbl = makeHashTable32( 16, &VMS_int__free ); 1.8 1.9 //TODO: bug -- turn these arrays into dyn arrays to eliminate limit 1.10 //semanticEnv->singletonHasBeenExecutedFlags = makeDynArrayInfo( ); 1.11 @@ -429,31 +430,50 @@ 1.12 //=========================================================================== 1.13 1.14 1.15 -//=========================================================================== 1.16 -/*Returns a taskID, which can be used to communicate between tasks with 1.17 - * send-receive, or to use other kinds of constructs with tasks. 1.18 +//======================= task submit and end ============================== 1.19 +/* 1.20 */ 1.21 -int32 1.22 +void 1.23 VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv) 1.24 { VSsSemReq reqData; 1.25 1.26 reqData.reqType = submit_task; 1.27 - reqData.callingSlv = animSlv; 1.28 + 1.29 reqData.taskType = taskType; 1.30 reqData.args = args; 1.31 + reqData.callingSlv = animSlv; 1.32 1.33 + reqData.taskID = NULL; 1.34 1.35 VMS_WL__send_sem_request( &reqData, animSlv ); 1.36 - return (int32)animSlv->dataRetFromReq; 1.37 } 1.38 1.39 -/*NOTE: if want, don't need to send the animating SlaveVP around.. 1.40 - * instead, can make a single slave per core, and coreCtrlr looks up the 1.41 - * slave from having the core number. 1.42 - * 1.43 - *But, to stay compatible with all the other VMS languages, leave it in.. 1.44 - * 1.45 - *This call is the last to happen in every task. It causes the slave to 1.46 +inline int32 * 1.47 +VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv ) 1.48 + { int32 *taskID; 1.49 + 1.50 + taskID = VMS_WL__malloc( sizeof(int32) + numInts * sizeof(int32) ); 1.51 + taskID[0] = numInts; 1.52 + return taskID; 1.53 + } 1.54 + 1.55 +void 1.56 +VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID, 1.57 + SlaveVP *animSlv) 1.58 + { VSsSemReq reqData; 1.59 + 1.60 + reqData.reqType = submit_task; 1.61 + 1.62 + reqData.taskType = taskType; 1.63 + reqData.args = args; 1.64 + reqData.taskID = taskID; 1.65 + reqData.callingSlv = animSlv; 1.66 + 1.67 + VMS_WL__send_sem_request( &reqData, animSlv ); 1.68 + } 1.69 + 1.70 + 1.71 +/*This call is the last to happen in every task. It causes the slave to 1.72 * suspend and get the next task out of the task-queue. Notice there is no 1.73 * assigner here.. only one slave, no slave ReadyQ, and so on.. 1.74 *Can either make the assigner take the next task out of the taskQ, or can 1.75 @@ -463,6 +483,12 @@ 1.76 * 1.77 *The task-stub is saved in the animSlv, so the request handler will get it 1.78 * from there, along with the task-type which has arg types, and so on.. 1.79 + * 1.80 + * NOTE: if want, don't need to send the animating SlaveVP around.. 1.81 + * instead, can make a single slave per core, and coreCtrlr looks up the 1.82 + * slave from having the core number. 1.83 + * 1.84 + *But, to stay compatible with all the other VMS languages, leave it in.. 1.85 */ 1.86 void 1.87 VSs__end_task( SlaveVP *animSlv ) 1.88 @@ -474,6 +500,108 @@ 1.89 VMS_WL__send_sem_request( &reqData, animSlv ); 1.90 } 1.91 1.92 + 1.93 +//========================== send and receive ============================ 1.94 +// 1.95 + 1.96 +inline int32 * 1.97 +VSs__give_self_taskID( SlaveVP *animSlv ) 1.98 + { 1.99 + return ((VSsSemData*)animSlv->semanticData)->taskStub->taskID; 1.100 + } 1.101 + 1.102 +//================================ send =================================== 1.103 + 1.104 +void 1.105 +VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID, 1.106 + SlaveVP *senderSlv ) 1.107 + { VSsSemReq reqData; 1.108 + 1.109 + reqData.reqType = send_type_to; 1.110 + 1.111 + reqData.msg = msg; 1.112 + reqData.msgType = type; 1.113 + reqData.receiverID = receiverID; 1.114 + reqData.senderSlv = senderSlv; 1.115 + 1.116 + reqData.nextReqInHashEntry = NULL; 1.117 + 1.118 + VMS_WL__send_sem_request( &reqData, senderSlv ); 1.119 + 1.120 + //When come back from suspend, no longer own data reachable from msg 1.121 + } 1.122 + 1.123 +void 1.124 +VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv ) 1.125 + { VSsSemReq reqData; 1.126 + 1.127 + reqData.reqType = send_from_to; 1.128 + 1.129 + reqData.msg = msg; 1.130 + reqData.senderID = senderID; 1.131 + reqData.receiverID = receiverID; 1.132 + reqData.senderSlv = senderSlv; 1.133 + 1.134 + reqData.nextReqInHashEntry = NULL; 1.135 + 1.136 + VMS_WL__send_sem_request( &reqData, senderSlv ); 1.137 + } 1.138 + 1.139 + 1.140 +//================================ receive ================================ 1.141 + 1.142 +/*The "type" version of send and receive creates a many-to-one relationship. 1.143 + * The sender is anonymous, and many sends can stack up, waiting to be 1.144 + * received. The same receiver can also have send from-to's 1.145 + * waiting for it, and those will be kept separate from the "type" 1.146 + * messages. 1.147 + */ 1.148 +void * 1.149 +VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv ) 1.150 + { DEBUG__printf1(dbgRqstHdlr,"WL: receive type to %d",receiverID[1] ); 1.151 + VSsSemReq reqData; 1.152 + 1.153 + reqData.reqType = receive_type_to; 1.154 + 1.155 + reqData.msgType = type; 1.156 + reqData.receiverID = receiverID; 1.157 + reqData.receiverSlv = receiverSlv; 1.158 + 1.159 + reqData.nextReqInHashEntry = NULL; 1.160 + 1.161 + VMS_WL__send_sem_request( &reqData, receiverSlv ); 1.162 + 1.163 + return receiverSlv->dataRetFromReq; 1.164 + } 1.165 + 1.166 + 1.167 + 1.168 +/*Call this at the point a receiving task wants in-coming data. 1.169 + * Use this from-to form when know senderID -- it makes a direct channel 1.170 + * between sender and receiver. 1.171 + */ 1.172 +void * 1.173 +VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv ) 1.174 + { 1.175 + VSsSemReq reqData; 1.176 + 1.177 + reqData.reqType = receive_from_to; 1.178 + 1.179 + reqData.senderID = senderID; 1.180 + reqData.receiverID = receiverID; 1.181 + reqData.receiverSlv = receiverSlv; 1.182 + 1.183 + reqData.nextReqInHashEntry = NULL; 1.184 + DEBUG__printf2(dbgRqstHdlr,"WL: receive from %d to: %d", reqData.senderID[1], reqData.receiverID[1]); 1.185 + 1.186 + VMS_WL__send_sem_request( &reqData, receiverSlv ); 1.187 + 1.188 + return receiverSlv->dataRetFromReq; 1.189 + } 1.190 + 1.191 + 1.192 + 1.193 + 1.194 //========================================================================== 1.195 // 1.196 /*A function singleton is a function whose body executes exactly once, on a
