Thanks a lot. 

In the following common seeing code segment, I notice someone add 'atomic'
before 'm_data = data;' (such as OscilloscopeRF), someone does not (such as
Delta from Moteiv). Since another 'dataReady' interupt could come before
task sendData is excuted, it seems to me the first 'atomic' is not necessary
-- even if you have, the 'm_data' will be changed before sendData excuted. 

Further more, if 'msg' will be modified here only, I even think the second
'atomic' is not necessary. Since one task will not preempt another task. In
other words, another post sendData will not excute until the current
sendData finish.

async event result_t ADC.dataReady(uint16_t data) {
    atomic m_data = data;
    post sendData();
    return SUCCESS;
  }

 task void sendData() {
    .....
    atomic msg->data = m_data; // assume msg will be modified here only  
 }  

It seems to me that 'atomic' is useful only if there are a set of variables
- you want to keep the integrity of the variable set.

Please give a quick a comment, I got confused with this quite a while ... 

-----Original Message-----
From: David Gay [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 13, 2006 11:00 AM
To: Adam
Cc: [email protected]
Subject: Re: [Tinyos-help] NesC and TinyOS

On 6/13/06, Adam <[EMAIL PROTECTED]> wrote:
> Page 39 Listing 4.24 in the Phil's manual says differently... I wish 
> what you said is correct - easier to manage. Please clarify. Thanks.

You're misinterpreting the text there. As Phil said in his answer, Listing
4.24 is an example of an optimisation where allowing async code to interrupt
an atomic statement would have no detectable effects. But in cases where the
effects would be detectable (i.e., if there is any shared state between the
atomic statement and anything that interrupts it), such an optimisation
would be illegal. It's all quite moot because we don't attempt to do such
optimisations at this point.

David Gay

_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to