[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/msp430/adc12 AdcC.nc, 1.1.2.10, 1.1.2.11

Jan-Hinrich Hauer janhauer at users.sourceforge.net
Fri Jun 2 10:42:27 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/adc12
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv10112/tos/chips/msp430/adc12

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	AdcC.nc 
Log Message:
Bugfix: Race-condition would occur when the data request to HAL1 was immediately followed by the dataReady signal, because the statemachine was not updated properly in this case.

Index: AdcC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/adc12/Attic/AdcC.nc,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -C2 -d -r1.1.2.10 -r1.1.2.11
*** AdcC.nc	17 Feb 2006 00:26:48 -0000	1.1.2.10
--- AdcC.nc	2 Jun 2006 17:42:24 -0000	1.1.2.11
***************
*** 64,73 ****
  implementation
  {
-   enum { // state
-     READ,
-     READ_NOW,
-     READ_STREAM
-   };
- 
    struct list_entry_t {
      uint16_t count;
--- 64,67 ----
***************
*** 75,84 ****
    };
    
!   // Resource interface makes norace safe
!   norace uint8_t state;
    norace uint8_t owner;
    norace uint16_t value;
!   norace bool ignore;
!   norace uint16_t *resultBuf;
    // atomic section in postBuffer() makes norace safe
    norace struct list_entry_t *streamBuf[uniqueCount(ADCC_READ_STREAM_SERVICE)];
--- 69,77 ----
    };
    
!   // Resource interface makes norace declaration safe
!   norace bool readSync;
    norace uint8_t owner;
    norace uint16_t value;
!   norace uint16_t *resultBuf; 
    // atomic section in postBuffer() makes norace safe
    norace struct list_entry_t *streamBuf[uniqueCount(ADCC_READ_STREAM_SERVICE)];
***************
*** 108,113 ****
      // reserved, because HAL1 checks ownership at runtime
      hal1request = call SingleChannel.getSingleData[client](&settings);
-     if (hal1request == SUCCESS)
-       state = READ_NOW;
      return hal1request;
    }
--- 101,104 ----
***************
*** 125,133 ****
        return;
      }
      hal1request = call SingleChannel.getSingleData[client](&settings);
!     if (hal1request == SUCCESS){
!       state = READ;
!       owner = client;
!     } else {
        call Resource.release[client]();
        signal Read.readDone[client](FAIL, 0);
--- 116,123 ----
        return;
      }
+     readSync = TRUE;
+     owner = client;
      hal1request = call SingleChannel.getSingleData[client](&settings);
!     if (hal1request != SUCCESS){
        call Resource.release[client]();
        signal Read.readDone[client](FAIL, 0);
***************
*** 143,160 ****
    async event error_t SingleChannel.singleDataReady[uint8_t client](uint16_t data)
    {
!     switch (state)
!     {
!       case READ:
!         value = data;
!         post readDone();
!         break;
!       case READ_NOW:  
!         if (ignore == TRUE)
!           ignore = FALSE;
!         else
!           signal ReadNow.readDone[client](SUCCESS, data);
!         break;
!       default:
!         break;
      }
      return SUCCESS;
--- 133,142 ----
    async event error_t SingleChannel.singleDataReady[uint8_t client](uint16_t data)
    {
!     if (readSync){ // was Read.read request
!       readSync = FALSE;
!       value = data;
!       post readDone();
!     } else { // was ReadNow.read request
!       signal ReadNow.readDone[client](SUCCESS, data);
      }
      return SUCCESS;



More information about the Tinyos-2-commits mailing list