From 53a8f111dd15982eb10d1a1e361a3ac341de8795 Mon Sep 17 00:00:00 2001 From: jzhou Date: Tue, 10 May 2011 17:57:28 +0000 Subject: [PATCH] Bug fix --- Robust/src/Runtime/bamboo/multicoremsg.c | 40 +++++++++++++----------- Robust/src/Runtime/bamboo/multicoremsg.h | 13 ++------ 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/Robust/src/Runtime/bamboo/multicoremsg.c b/Robust/src/Runtime/bamboo/multicoremsg.c index 5d0cd69d..5d6ffb4f 100644 --- a/Robust/src/Runtime/bamboo/multicoremsg.c +++ b/Robust/src/Runtime/bamboo/multicoremsg.c @@ -7,7 +7,7 @@ int msgsizearray[] = { 0, //MSGSTART, - -1, //TRANSOBJ, // 0xD1 + -1, //TRANSOBJ, // 0xD1 4, //TRANSTALL, // 0xD2 5, //LOCKREQUEST, // 0xD3 4, //LOCKGROUNT, // 0xD4 @@ -31,51 +31,53 @@ int msgsizearray[] = { 2, //GCSTARTCOMPACT, // 0xE5 1, //GCSTARTFLUSH, // 0xE6 4, //GCFINISHPRE, // 0xE7 - 2,//GCFINISHINIT, // 0xE8 + 2, //GCFINISHINIT, // 0xE8 4, //GCFINISHMARK, // 0xE9 5, //GCFINISHCOMPACT, // 0xEa - 2,//GCFINISHFLUSH, // 0xEb + 2, //GCFINISHFLUSH, // 0xEb 1, //GCFINISH, // 0xEc 1, //GCMARKCONFIRM, // 0xEd 5, //GCMARKREPORT, // 0xEe 2, //GCMARKEDOBJ, // 0xEf 4, //GCMOVESTART, // 0xF0 1, //GCLOBJREQUEST, // 0xF1 - -1, //GCLOBJINFO, // 0xF2 + -1, //GCLOBJINFO, // 0xF2 #ifdef GC_PROFILE 4, //GCPROFILES, // 0xF3 #endif // GC_PROFILE #ifdef GC_CACHE_ADAPT - -2, //GCSTARTPOSTINIT, // 0xF4 1, //GCSTARTPREF, // 0xF5 - -2, //GCFINISHPOSTINIT, // 0xF6 2, //GCFINISHPREF, // 0xF7 #endif // GC_CACHE_ADAPT #endif // MULTICORE_GC - -1//MSGEND + -1 //MSGEND }; -INLINE unsigned int checkMsgLength_I() { +INLINE unsigned int checkMsgLength_I(unsigned int * type) { #if (defined(TASK)||defined(MULTICORE_GC)) unsigned int realtype = msgdata[msgdataindex]; - unsigned int type=realtype&0xff; + *type=realtype&0xff; #else - unsigned int type = msgdata[msgdataindex]; + *type = msgdata[msgdataindex]; #endif + if(*type>MSGEND) { + // invalid msg type + BAMBOO_EXIT(); + } #ifdef TASK #ifdef MULTICORE_GC - if(type==TRANSOBJ||type==GCLOBJINFO) { + if(*type==TRANSOBJ||*type==GCLOBJINFO) { #else - if(type==TRANSOBJ) { + if(*type==TRANSOBJ) { #endif #elif MULTICORE_GC - if (type==GCLOBJINFO) { + if (*type==GCLOBJINFO) { #endif #if (defined(TASK)||defined(MULTICORE_GC)) return realtype>>8; } #endif - return msgsizearray[type]; + return msgsizearray[*type]; } INLINE void processmsg_transobj_I(int msglength) { @@ -699,6 +701,9 @@ int receiveObject_I() { msg: // get the incoming msgs receiveMsg_I(); + if((msgdataindex == msgdatalast) && (!msgdatafull)) { + return -1; + } if(BAMBOO_CHECK_SEND_MODE()) { // during send, don't process the msg now return -3; @@ -718,12 +723,11 @@ processmsg: } //we only ever read the first word - unsigned int msglength = checkMsgLength_I(); - + MSGTYPE type; + unsigned int msglength = checkMsgLength_I((unsigned int*)(&type)); + if(msglength <= size) { // have some whole msg - MSGTYPE type; - type = msgdata[msgdataindex]; //[0] MSG_INDEXINC_I(); msgdatafull = false; switch(type) { diff --git a/Robust/src/Runtime/bamboo/multicoremsg.h b/Robust/src/Runtime/bamboo/multicoremsg.h index 9f5b503a..56bc67e1 100644 --- a/Robust/src/Runtime/bamboo/multicoremsg.h +++ b/Robust/src/Runtime/bamboo/multicoremsg.h @@ -10,8 +10,6 @@ int msgdata[BAMBOO_MSG_BUF_LENGTH]; volatile int msgdataindex; volatile int msgdatalast; -//BAD! BAD! BAD! THIS SHOULD NOT BE A GLOBAL!!!! -//int msglength; volatile bool msgdatafull; int outmsgdata[BAMBOO_OUT_BUF_LENGTH]; int outmsgindex; @@ -29,9 +27,6 @@ volatile bool isMsgHanging; msgdata[msgdatalast] = (n); \ MSG_LASTINDEXINC_I() -// NOTE: if msgdataindex == msgdatalast, it always means that the buffer if -// full. In the case that the buffer is empty, should never call this -// MACRO #define MSG_REMAINSIZE_I(s) \ if(msgdataindex < msgdatalast) { \ (*(int*)s) = msgdatalast - msgdataindex; \ @@ -157,7 +152,7 @@ volatile bool isMsgHanging; * (size is always 3 * sizeof(int)) */ typedef enum { - MSGSTART = 0x0, // 0xD0 + MSGSTART = 0x0, // 0xD0 TRANSOBJ, // 0xD1 TRANSTALL, // 0xD2 LOCKREQUEST, // 0xD3 @@ -197,10 +192,8 @@ typedef enum { GCPROFILES, // 0xF3 #endif // GC_PROFILE #ifdef GC_CACHE_ADAPT - GCSTARTPOSTINIT, // 0xF4 - GCSTARTPREF, // 0xF5 - GCFINISHPOSTINIT, // 0xF6 - GCFINISHPREF, // 0xF7 + GCSTARTPREF, // 0xF4 + GCFINISHPREF, // 0xF5 #endif // GC_CACHE_ADAPT #endif // MULTICORE_GC MSGEND -- 2.34.1