From 2ebc8a595e9a1d26eb70715383a374abc1399edf Mon Sep 17 00:00:00 2001 From: Daniela Genius <genius@debussy.soc.lip6.fr> Date: Wed, 8 Feb 2017 18:16:32 +0100 Subject: [PATCH] bugfix syncchannel (encore) --- MPSoC/src/syncchannel.c | 82 +---------------------------------------- 1 file changed, 1 insertion(+), 81 deletions(-) diff --git a/MPSoC/src/syncchannel.c b/MPSoC/src/syncchannel.c index d43a6c892a..09dad20df3 100755 --- a/MPSoC/src/syncchannel.c +++ b/MPSoC/src/syncchannel.c @@ -6,11 +6,9 @@ #include "myerrors.h" #include "debug.h" #include "mwmr.h" -//#include "random.h" /* this function empties a channel and is called after one send or receive transaction */ - void mwmr_sync_flush(struct mwmr_s *fifo){ int i=1; while(i){ @@ -20,85 +18,18 @@ void mwmr_sync_flush(struct mwmr_s *fifo){ /* all synchronous communications use MWMR channels of size 1, enforcing synchronization */ -/*void sync_read( struct mwmr_s *fifo, void *_ptr){ - int in; - while(1){ - - if(!(in=mwmr_try_read(fifo,_ptr,1))) continue; - } - return; - }*/ -//DG 8.2.2017 -int sync_read( struct mwmr_s *fifo, void *_ptr, int lensw ){ - // debugMsg("###before write "); - mwmr_write(fifo,_ptr,1); +int sync_read( struct mwmr_s *fifo, void *_ptr, int lensw ){ debugMsg("###before read "); mwmr_read(fifo,_ptr,1); debugMsg("###after read "); } -//DG 7.2.2017 -/*int sync_read( struct mwmr_s *fifo, void *_ptr, int lensw ){ - int in; -debugMsg("###before try read \n"); - in = mwmr_try_read(fifo,_ptr,lensw); -debugInt("###after try read: %x \n",in); - return in; - }*/ - -/* in the case of multi_writer one channel per writer */ -/* we choose ramdomly one of the channels */ -/* the problem is to identify the channels on the side of the writers which can be in different blocks */ - -void sync_read_random( struct mwmr_s *fifo[], void *_ptr, int nb_writers){ - int in; - int rand = computeRandom(0, nb_writers-1); - while(1){ - /* loop until one single message has been read successfully */ - rand = computeRandom(0, nb_writers-1); -debugMsg("####mwmr channel before try readn"); - if(!(in=mwmr_try_read(fifo[rand],_ptr,1))) continue; - debugInt("####mwmr channel after try read: ",in); -debugMsg("\n"); - } - return; -} -/*void sync_write(struct mwmr_s *fifo, void *_ptr){ - int out; - out=mwmr_try_write(fifo,NULL,1); - if(out==0){ - - printf("message lost\n"); - } - return; - }*/ -//DG 8.2.2017 int sync_write( struct mwmr_s *fifo, void *_ptr, int lensw ){ debugMsg("###mwmr channel before write "); mwmr_write(fifo,_ptr,1); debugMsg("####mwmr channel after write: "); } -/* the task issueing the message does not continue until THIS PARTICULAR message has been successfully taken by another task; an additional empty sync message is issued for that purpose, in a busy waiting loop; once synchronization has been achieved, this message is flushed and a blocking write initiated */ - -/*void sync_write_random(struct mwmr_s *fifo[], void *_ptr, int id_writer){ - int out; - while(1){ - mwmr_lock(fifo[id_writer]); - out=mwmr_try_write(fifo[id_writer],NULL,1); - if(out==0){ - mwmr_unlock(fifo[id_writer]); - continue; - } - mwmr_sync_flush(fifo[id_writer]); - mwmr_write(fifo[id_writer],_ptr,1); - mwmr_unlock(fifo[id_writer]); - } - return; - }*/ - -//DG 7.9. add MWMR as parameter -//syncchannel *getNewSyncchannel(char *outname, char *inname, struct mwmr_s *fifo) { syncchannel *getNewSyncchannel(char *outname, char *inname, struct mwmr_s *fifo) { syncchannel * syncch = (syncchannel *)(malloc(sizeof(struct syncchannel))); if (syncch == NULL) { @@ -109,7 +40,6 @@ syncchannel *getNewSyncchannel(char *outname, char *inname, struct mwmr_s *fifo) syncch->inWaitQueue = NULL; syncch->outWaitQueue = NULL; syncch->isBroadcast = false; - //DG 7.9. add MWMR syncch->mwmr_fifo=fifo; return syncch; } @@ -118,16 +48,6 @@ void setBroadcast(syncchannel *syncch, bool b) { syncch->isBroadcast = b; } -/*request *makeNewSendSync(int hasDelay, long delay, int nbOfParams, int *params[]) { - request *req = getNewRequest(SEND_SYNC_REQUEST, hasDelay, delay, nbOfParams, params); - return req; -} - -request *makeNewReceiveSync(int hasDelay, long delay, int nbOfParams, int *params[]) { - request *req = getNewRequest(RECEIVE_SYNC_REQUEST, hasDelay, delay, nbOfParams, params); - return req; - }*/ - void destroySyncchannel(syncchannel *syncch) { free(syncch); -- GitLab