# HG changeset patch # User Me # Date 1280348169 25200 # Node ID 9f2e23d38ff23ad952f3fdf6c5c841c4da044e49 # Parent f6b960f400051199cd49f30074b78a41b09e0dd2 Works Sequentially -- first debugged version fully working diff -r f6b960f40005 -r 9f2e23d38ff2 VMSHW.h --- a/VMSHW.h Mon Jul 26 15:26:57 2010 -0700 +++ b/VMSHW.h Wed Jul 28 13:16:09 2010 -0700 @@ -62,7 +62,7 @@ VMSHW__init(); void -VMSHW__shutdown(); +VMSHW__cleanup_after_shutdown(); //======================= diff -r f6b960f40005 -r 9f2e23d38ff2 VMSHW_PluginFns.c --- a/VMSHW_PluginFns.c Mon Jul 26 15:26:57 2010 -0700 +++ b/VMSHW_PluginFns.c Wed Jul 28 13:16:09 2010 -0700 @@ -71,14 +71,13 @@ { //free any semantic data allocated to the virt procr - //Now, call VMS's dissipate fn, which will free stack and rest - VMS__dissipate_procr( requestingPr ); + //Now, call VMS to free_all AppVP state -- stack and so on + VMS__handle_dissipate_reqst( requestingPr ); semEnv->numVirtPr -= 1; if( semEnv->numVirtPr == 0 ) - { //no more work, so shutdown -- create shutdown procr & Q it - VirtProcr * shutdownPr = VMS__create_the_shutdown_procr(); - writePrivQ( shutdownPr, semEnv->readyVirtProcrQ ); + { //no more work, so shutdown + VMS__handle_shutdown_reqst( requestingPr ); } } diff -r f6b960f40005 -r 9f2e23d38ff2 VMSHW_Request_Handlers.c --- a/VMSHW_Request_Handlers.c Mon Jul 26 15:26:57 2010 -0700 +++ b/VMSHW_Request_Handlers.c Wed Jul 28 13:16:09 2010 -0700 @@ -95,6 +95,8 @@ { //waiting request is another send, so stack this up on list semReq-> nextReqInHashEntry = waitingReq->nextReqInHashEntry; waitingReq->nextReqInHashEntry = semReq; + printf("linked requests: %d, %d | ", semReq, waitingReq ); + printf("type: %d, %d\n", semReq->reqType, waitingReq->reqType ); return; } else @@ -151,11 +153,16 @@ { printf("\n ERROR: shouldn't be two send from-tos waiting \n"); } else - { //waiting request is a receive, so pair it to this send - //first, remove the waiting receive request from the list in entry + { //waiting request is a receive, so it completes pair with this send + + //remove the waiting receive request from the entry entry->content = waitingReq->nextReqInHashEntry; //can only be one waiting req for "from-to" semantics - if( entry->content != NULL ) printf("\nERROR in handleSendFromTo\n"); + if( entry->content != NULL ) + { + printf("\nERROR in handleSendFromTo\n"); + printf("waitReq: %d | next req: %d\n", waitingReq, entry->content); + } deleteEntryFromTable( entry->key, commHashTbl ); //frees entry too //attach msg that's in this send request to receiving procr diff -r f6b960f40005 -r 9f2e23d38ff2 VMSHW_lib.c --- a/VMSHW_lib.c Mon Jul 26 15:26:57 2010 -0700 +++ b/VMSHW_lib.c Wed Jul 28 13:16:09 2010 -0700 @@ -14,6 +14,12 @@ #include "VMS/Hash_impl/PrivateHash.h" +//========================================================================== + +void +VMSHW__init_Seq(); +//========================================================================== + /*TODO: Q: dealing with library f()s and DKU vs WT vs FoR * (still want to do FoR, with time-lines as syntax, could be super cool) @@ -92,14 +98,13 @@ //NOTE: no Threads should exist in the outside program that might touch // any of the data reachable from initData given to the seed procr - VMS__start_the_work_then_wait_until_done(); +// VMS__start_the_work_then_wait_until_done(); + VMS__start_the_work_then_wait_until_done_Seq(); - VMSHW__shutdown(); + VMSHW__cleanup_after_shutdown(); } - - //=========================================================================== /*Initializes all the data-structures for a VMSHW system -- but doesn't @@ -115,7 +120,8 @@ VMSHW__init() { VMSHWSemEnv *semanticEnv; - VMS__init(); +// VMS__init(); + VMS__init_Seq(); //masterEnv, a global var, now is partially set up by init_VMS //Hook up the semantic layer's plug-ins to the Master virt procr @@ -135,20 +141,21 @@ semanticEnv->commHashTbl = makeHashTable( 1<<16, NULL ); //start big } + /*Frees any memory allocated by VMSHW__init() then calls VMS__shutdown */ void -VMSHW__shutdown() +VMSHW__cleanup_after_shutdown() { VMSHWSemEnv *semanticEnv; semanticEnv = _VMSMasterEnv->semanticEnv; - //TODO: double check all sem env locations freed +//TODO: double check all sem env locations freed free( semanticEnv->readyVirtProcrQ->startOfData ); free( semanticEnv->readyVirtProcrQ ); freeHashTable( semanticEnv->commHashTbl ); free( _VMSMasterEnv->semanticEnv ); - VMS__shutdown(); + VMS__cleanup_after_shutdown(); } @@ -250,6 +257,7 @@ reqData->reqType = send_type; reqData->msgType = type; reqData->msg = msg; + reqData->nextReqInHashEntry = NULL; //On ownership -- remove inside the send and let ownership sit in limbo // as a potential in an entry in the hash table, when this receive msg @@ -274,6 +282,7 @@ reqData->sendPr = sendPr; reqData->reqType = send_from_to; reqData->msg = msg; + reqData->nextReqInHashEntry = NULL; //On ownership -- remove inside the send and let ownership sit in limbo // as a potential in an entry in the hash table, when this receive msg @@ -304,6 +313,7 @@ reqData->receivePr = receivePr; reqData->reqType = receive_type; reqData->msgType = type; + reqData->nextReqInHashEntry = NULL; VMS__add_sem_request( reqData, receivePr ); VMS__suspend_procr( receivePr ); @@ -330,6 +340,7 @@ reqData->receivePr = receivePr; reqData->sendPr = sendPr; reqData->reqType = receive_from_to; + reqData->nextReqInHashEntry = NULL; //On ownership -- remove inside the send after receive successful. // Below, add ownership when come back from suspend