[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/Deluge Deluge.h, 1.3, 1.4 DelugeM.nc, 1.4, 1.5 DelugeMetadataM.nc, 1.4, 1.5 DelugeMsgs.h, 1.2, 1.3 DelugePageTransfer.nc, 1.2, 1.3 DelugePageTransferM.nc, 1.3, 1.4 DelugeImgDescStorage.nc, 1.1, NONE DelugePageTransfer.h, 1.1, NONE

Jonathan Hui jwhui at users.sourceforge.net
Mon Jan 3 09:34:57 PST 2005


Update of /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4645

Modified Files:
	Deluge.h DelugeM.nc DelugeMetadataM.nc DelugeMsgs.h 
	DelugePageTransfer.nc DelugePageTransferM.nc 
Removed Files:
	DelugeImgDescStorage.nc DelugePageTransfer.h 
Log Message:
- Improved performance. Single hop 20K program without TOSBase 40-45
seconds.

- Fixed a bug where nodes advertising slowly failed to increase their
rate when receiving an advertisement indicating inconsitancies between
nodes. The bug's effect was that nodes did not attempt to update their
images for a long time.



Index: Deluge.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/Deluge.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Deluge.h	26 Nov 2004 18:59:10 -0000	1.3
--- Deluge.h	3 Jan 2005 17:34:54 -0000	1.4
***************
*** 37,41 ****
    DELUGE_VERSION                    = 2,
    DELUGE_NUM_IMAGES                 = 3,
!   DELUGE_MIN_ADV_PERIOD_LOG2        = 9,
    DELUGE_MAX_ADV_PERIOD_LOG2        = 20,
    DELUGE_NUM_NEWDATA_ADVS_REQUIRED  = 2,
--- 37,41 ----
    DELUGE_VERSION                    = 2,
    DELUGE_NUM_IMAGES                 = 3,
!   DELUGE_MIN_ADV_PERIOD_LOG2        = 8,
    DELUGE_MAX_ADV_PERIOD_LOG2        = 20,
    DELUGE_NUM_NEWDATA_ADVS_REQUIRED  = 2,
***************
*** 64,70 ****
    DELUGE_INVALID_PKTNUM             = 0xff,
    DELUGE_INVALID_PGNUM              = 0xff,
!   DELUGE_IMAGE0_VOLUME              = unique("FlashVolume"),
!   DELUGE_IMAGE1_VOLUME              = unique("FlashVolume"),
!   DELUGE_IMAGE2_VOLUME              = unique("FlashVolume"),
  };
  
--- 64,73 ----
    DELUGE_INVALID_PKTNUM             = 0xff,
    DELUGE_INVALID_PGNUM              = 0xff,
! };
! 
! static const uint8_t DELUGE_VOLUMES[] = {
!   unique("FlashVolume"),
!   unique("FlashVolume"),
!   unique("FlashVolume"),
  };
  
***************
*** 79,86 ****
  
  typedef struct DelugeAdvTimer {
!   uint32_t timer;
!   uint8_t periodLog2;
!   bool overheard;
!   uint8_t  newAdvs;
  } DelugeAdvTimer;
  
--- 82,89 ----
  
  typedef struct DelugeAdvTimer {
!   uint32_t timer      : 24;
!   uint8_t  periodLog2 : 8;
!   bool     overheard  : 8;
!   uint8_t  newAdvs    : 8;
  } DelugeAdvTimer;
  

Index: DelugeM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeM.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DelugeM.nc	27 Nov 2004 04:50:30 -0000	1.4
--- DelugeM.nc	3 Jan 2005 17:34:54 -0000	1.5
***************
*** 63,66 ****
--- 63,67 ----
      advTimers[timerNum].timer = (uint32_t)0x1 << (advTimers[timerNum].periodLog2-1);
      advTimers[timerNum].timer += call Random.rand() & (advTimers[timerNum].timer-1);
+     advTimers[timerNum].overheard = 0;
    }
  
***************
*** 101,104 ****
--- 102,121 ----
    }
  
+   void setNextPage() {
+ 
+     DelugeImgDesc imgDesc;
+     uint8_t i;
+ 
+     for ( i = 0; i < DELUGE_NUM_IMAGES; i++ ) {
+       call Metadata.getImgDesc(i, &imgDesc);
+       if (imgDesc.numPgs != imgDesc.numPgsComplete)
+ 	break;
+     }
+ 
+     if (i < DELUGE_NUM_IMAGES)
+       call PageTransfer.setWorkingPage(i, imgDesc.numPgsComplete);
+ 
+   }
+ 
    command result_t StdControl.init() {
      result_t result;
***************
*** 129,132 ****
--- 146,151 ----
      uint8_t i;
  
+     setNextPage();
+ 
      for ( i = 0; i < DELUGE_NUM_TIMERS; i++ ) {
        advTimers[i].periodLog2 = DELUGE_MIN_ADV_PERIOD_LOG2;
***************
*** 165,179 ****
        call Leds.yellowOff();
  
-     call Leds.greenToggle();
- 
      updateTimers();
  
      if (!advTimers[minTimer].overheard
! 	&& !call SharedMsgBuf.isLocked()
! 	&& !call PageTransfer.isTransferring()) {
        TOS_MsgPtr pMsgBuf = call SharedMsgBuf.getMsgBuf();
        fillAdvMsg(minTimer+1, (DelugeAdvMsg*)(pMsgBuf->data));
!       if (call SendAdvMsg.send(TOS_BCAST_ADDR, sizeof(DelugeAdvMsg), pMsgBuf) == SUCCESS)
  	call SharedMsgBuf.lock();
      }
  
--- 184,197 ----
        call Leds.yellowOff();
  
      updateTimers();
  
      if (!advTimers[minTimer].overheard
! 	&& !call SharedMsgBuf.isLocked()) {
        TOS_MsgPtr pMsgBuf = call SharedMsgBuf.getMsgBuf();
        fillAdvMsg(minTimer+1, (DelugeAdvMsg*)(pMsgBuf->data));
!       if (call SendAdvMsg.send(TOS_BCAST_ADDR, sizeof(DelugeAdvMsg), pMsgBuf) == SUCCESS) {
! 	call Leds.greenToggle();
  	call SharedMsgBuf.lock();
+       }
      }
  
***************
*** 192,202 ****
      }
      else if (advTimers[minTimer].newAdvs == 0
- 	     && rebootDelay == 0
  	     && advTimers[minTimer].periodLog2 < DELUGE_MAX_ADV_PERIOD_LOG2) {
        advTimers[minTimer].periodLog2++;
      }
  
-     advTimers[minTimer].overheard = 0;
-     
      setupAdvTimer(minTimer);
      
--- 210,217 ----
***************
*** 224,234 ****
      dm_cmp_t cmpResult = call Metadata.compareImgDesc(&(rxAdvMsg->imgDesc));
  
!     if (rxAdvMsg->version != DELUGE_VERSION)
!       return pMsg;
! 
!     if (!call Metadata.isImgDescValid(&(rxAdvMsg->imgDesc))
  	|| !isNodeDescValid(&rxAdvMsg->nodeDesc))
        return pMsg;
! 
      if (rxAdvMsg->type == DELUGE_ADV_PC) {
        // adv message from PC
--- 239,247 ----
      dm_cmp_t cmpResult = call Metadata.compareImgDesc(&(rxAdvMsg->imgDesc));
  
!     if (rxAdvMsg->version != DELUGE_VERSION
! 	|| !call Metadata.isImgDescValid(&(rxAdvMsg->imgDesc))
  	|| !isNodeDescValid(&rxAdvMsg->nodeDesc))
        return pMsg;
!     
      if (rxAdvMsg->type == DELUGE_ADV_PC) {
        // adv message from PC
***************
*** 266,270 ****
        }
  
!       if (cmpResult != DELUGE_IMGDESC_EQUAL
  	  && advTimers[imgNum-1].periodLog2 != DELUGE_MIN_ADV_PERIOD_LOG2) {
  	advTimers[imgNum-1].periodLog2 = DELUGE_MIN_ADV_PERIOD_LOG2;
--- 279,284 ----
        }
  
!       if ((cmpResult != DELUGE_IMGDESC_EQUAL
! 	   || rxAdvMsg->nodeDesc.vNum != nodeDesc.vNum)
  	  && advTimers[imgNum-1].periodLog2 != DELUGE_MIN_ADV_PERIOD_LOG2) {
  	advTimers[imgNum-1].periodLog2 = DELUGE_MIN_ADV_PERIOD_LOG2;
***************
*** 290,309 ****
    }
  
-   void setNextPage() {
- 
-     DelugeImgDesc imgDesc;
-     uint8_t i;
- 
-     for ( i = 0; i < DELUGE_NUM_IMAGES; i++ ) {
-       call Metadata.getImgDesc(i, &imgDesc);
-       if (imgDesc.numPgs != imgDesc.numPgsComplete)
- 	break;
-     }
- 
-     if (i < DELUGE_NUM_IMAGES)
-       call PageTransfer.setWorkingPage(i, imgDesc.numPgsComplete);
- 
-   }
- 
    event result_t Metadata.setupNewImageDone(result_t result) {
      setNextPage();
--- 304,307 ----
***************
*** 322,329 ****
--- 320,334 ----
    }
  
+   event result_t PageTransfer.suppressMsgs(imgnum_t imgNum) {
+     advTimers[imgNum-1].overheard = 1;
+     return SUCCESS;
+   }
+ 
    event result_t Metadata.receivedPageDone(result_t result) {
  
      imgnum_t imgNum;
  
+     call Leds.yellowOn();
+ 
      setNextPage();
  

Index: DelugeMetadataM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeMetadataM.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DelugeMetadataM.nc	27 Nov 2004 17:36:41 -0000	1.4
--- DelugeMetadataM.nc	3 Jan 2005 17:34:54 -0000	1.5
***************
*** 185,190 ****
      curImage = imgNum;
  
!     if (call DataRead.verify(curImage, pgNum) == FAIL)
!       post retry();
  
      return SUCCESS;
--- 185,191 ----
      curImage = imgNum;
  
! //    if (call DataRead.verify(curImage, pgNum) == FAIL)
! //      post retry();
!     signal DataRead.verifyDone(SUCCESS);
  
      return SUCCESS;
***************
*** 288,292 ****
        return DELUGE_IMGDESC_EQUAL;
  
!     if ((cmpImgDesc->vNum - imgDesc[image].vNum) > 0)
        return DELUGE_IMGDESC_NEWER;
      else if ((cmpImgDesc->vNum - imgDesc[image].vNum) < 0)
--- 289,299 ----
        return DELUGE_IMGDESC_EQUAL;
  
!     if (cmpImgDesc->vNum == DELUGE_INVALID_VNUM
! 	&& imgDesc[image].vNum != DELUGE_INVALID_VNUM)
!       return DELUGE_IMGDESC_OLDER;
!     else if (cmpImgDesc->vNum != DELUGE_INVALID_VNUM
! 	     && imgDesc[image].vNum == DELUGE_INVALID_VNUM)
!       return DELUGE_IMGDESC_NEWER;
!     else if ((cmpImgDesc->vNum - imgDesc[image].vNum) > 0)
        return DELUGE_IMGDESC_NEWER;
      else if ((cmpImgDesc->vNum - imgDesc[image].vNum) < 0)

Index: DelugeMsgs.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeMsgs.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DelugeMsgs.h	26 Nov 2004 18:59:10 -0000	1.2
--- DelugeMsgs.h	3 Jan 2005 17:34:54 -0000	1.3
***************
*** 43,47 ****
    AM_DELUGEREQMSG       = 162,
    AM_DELUGEDATAMSG      = 163,
-   AM_DELUGEPINGREPLYMSG = 164,
  };
  
--- 43,46 ----

Index: DelugePageTransfer.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugePageTransfer.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DelugePageTransfer.nc	26 Nov 2004 18:59:10 -0000	1.2
--- DelugePageTransfer.nc	3 Jan 2005 17:34:54 -0000	1.3
***************
*** 36,38 ****
--- 36,39 ----
    command result_t dataAvailable(uint16_t sourceAddr, imgnum_t imgNum);
    event   result_t receivedPage(imgnum_t imgNum, pgnum_t pgNum);
+   event   result_t suppressMsgs(imgnum_t imgNum);
  }

Index: DelugePageTransferM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugePageTransferM.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** DelugePageTransferM.nc	26 Nov 2004 18:59:10 -0000	1.3
--- DelugePageTransferM.nc	3 Jan 2005 17:34:54 -0000	1.4
***************
*** 104,113 ****
    void changeState(uint8_t newState) {
      
!     switch(newState) {
!     case S_DISABLED: case S_IDLE:
!       if (state == S_SENDING || state == S_RECEIVING)
! 	call SharedMsgBuf.unlock();
!       break;
!     }
  
      state = newState;
--- 104,110 ----
    void changeState(uint8_t newState) {
      
!     if ((newState == S_DISABLED || newState == S_IDLE)
! 	&& (state == S_SENDING || state == S_RECEIVING))
!       call SharedMsgBuf.unlock();
  
      state = newState;
***************
*** 193,196 ****
--- 190,195 ----
        return;
  
+     signal PageTransfer.suppressMsgs(vars.tx.imgToSend);
+ 
      if (state == S_TX_LOCKING) {
        if (call SharedMsgBuf.lock() == FAIL) {
***************
*** 361,377 ****
      DelugeReqMsg *pReqMsg = (DelugeReqMsg*)(pMsgBuf->data);
      DelugeDataMsg *rxDataMsg = (DelugeDataMsg*)(pMsg->data);
-     uint16_t tmp;
  
      dbg(DBG_USR1, "DELUGE: Received DATA_MSG(vNum=%d,imgNum=%d,pgNum=%d,pktNum=%d)\n",
  	rxDataMsg->vNum, rxDataMsg->imgNum, rxDataMsg->pgNum, rxDataMsg->pktNum);
  
!     if (state == S_DISABLED)
!       return pMsg;
! 
!     if (workingImgNum == DELUGE_INVALID_IMGNUM)
        return pMsg;
  
      if (rxDataMsg->vNum == call Metadata.getVNum(workingImgNum)
! 	&& rxDataMsg->imgNum == workingImgNum
  	&& rxDataMsg->pgNum <= workingPgNum) {
        
--- 360,373 ----
      DelugeReqMsg *pReqMsg = (DelugeReqMsg*)(pMsgBuf->data);
      DelugeDataMsg *rxDataMsg = (DelugeDataMsg*)(pMsg->data);
  
      dbg(DBG_USR1, "DELUGE: Received DATA_MSG(vNum=%d,imgNum=%d,pgNum=%d,pktNum=%d)\n",
  	rxDataMsg->vNum, rxDataMsg->imgNum, rxDataMsg->pgNum, rxDataMsg->pktNum);
  
!     if (state == S_DISABLED
! 	|| workingImgNum == DELUGE_INVALID_IMGNUM)
        return pMsg;
  
      if (rxDataMsg->vNum == call Metadata.getVNum(workingImgNum)
! 	&& rxDataMsg->imgNum <= workingImgNum
  	&& rxDataMsg->pgNum <= workingPgNum) {
        
***************
*** 395,403 ****
  	memcpy(dataQ[(dataQHead+dataQLen)%DELUGE_DATA_Q_SIZE].data, rxDataMsg->data, DELUGE_PKT_PAYLOAD_SIZE);
  	dataQLen++;
! 	if (dataQLen == 1) {
! 	  if (call DataWrite.write(workingImgNum, calcOffset(workingPgNum, dataQ[dataQHead].pktNum),
! 				   dataQ[dataQHead].data, DELUGE_PKT_PAYLOAD_SIZE) == FAIL)
! 	    post writeData();
! 	}
  
  	// mark packet as received in request packet
--- 391,396 ----
  	memcpy(dataQ[(dataQHead+dataQLen)%DELUGE_DATA_Q_SIZE].data, rxDataMsg->data, DELUGE_PKT_PAYLOAD_SIZE);
  	dataQLen++;
! 	if (dataQLen == 1)
! 	  post writeData();
  
  	// mark packet as received in request packet
***************
*** 405,412 ****
  	if (state == S_RECEIVING)
  	  BITVEC_CLEAR(pReqMsg->requestedPkts, rxDataMsg->pktNum);
- 
- 	// stop requests if all packets are received
- 	if (!call BitVecUtils.indexOf(&tmp, 0, pktsToReceive, DELUGE_PKTS_PER_PAGE))
- 	  call ReqTimer.stop();
        }
      }
--- 398,401 ----
***************
*** 452,461 ****
      uint16_t tmp;
  
-     if (result == FAIL) {
-       // fail, something bad happened, try again
-       post writeData();
-       return SUCCESS;
-     }
-     
      if (dataQLen > 0) {
        dataQHead = (dataQHead + 1) % DELUGE_DATA_Q_SIZE;
--- 441,444 ----
***************
*** 511,515 ****
  
      BITVEC_CLEAR(pktsToSend, pDataMsg->pktNum);
!     if (pDataMsg->pktNum == DELUGE_PKTS_PER_PAGE - 1)
        pDataMsg->pktNum = 0;
  
--- 494,498 ----
  
      BITVEC_CLEAR(pktsToSend, pDataMsg->pktNum);
!     if (pDataMsg->pktNum >= DELUGE_PKTS_PER_PAGE - 1)
        pDataMsg->pktNum = 0;
  

--- DelugeImgDescStorage.nc DELETED ---

--- DelugePageTransfer.h DELETED ---



More information about the Tinyos-beta-commits mailing list