Hi Xiaohui, The tinyos programming book is right. I have checked that CtpRoutingEngineP and it has no async command or event, so everything is updated in synchronous context. I also do not see that a pointer would be passed out of this module to these variables, so really all updates are synchronous and the atomic statements should be removed.
The ncc compiler is doing an excellent job: if you remove the atomic statements and it does not complain, then you do not need the atomic statements. There are only two cases where you need atomic even in sync context: 1) if your variable is updated through a pointer in an atomic context (which is rare, but can happen), 2) you are writing a hardware driver doing some time sensitive stuff and you do not want your code to be interrupted in the middle. Hope this helps. Miklos On Sat, Jun 5, 2010 at 9:48 PM, Ali Baharev <[email protected]> wrote: > You did choose a notoriously difficult example :) > > The state_is_root is in an atomic block with routeInfo, it suggest > that they take part in invariants. Something similar to the example on > page 197 in the TinyOS Programming book. > > http://en.wikipedia.org/wiki/Invariant_%28computer_science%29 > > I could not track down in the code but I suspect that routeInfo, > directly or indirectly, can be accessed from async context. > > Ali > _______________________________________________ > Tinyos-help mailing list > [email protected] > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
