Hello all,
1) I have the following code snippet:
*uint8_t a;*
*
*
*async event void Alarm1.fired() {*
* a = 0;*
*}*
This compiles successfully without any warning. Isn't there a racing
condition here, between Alarm1 and itself?
2) If the following is added.
*async event void Alarm2.fired() {*
* a = 1;*
*}*
Still, this compiles successfully without any warning. Isn't there an
additional racing condition here, between Alarm1 and Alarm2 (and Alarm2 and
itself)?
3) If the following is added.
*event void Timer.fired() {*
* a = 2;*
*}*
Then there is a warning, "non-atomic accesses to shared variable `a'". Why
is there no warning for
*a = 0;*
in Alarm1?
According to the TinyOS book P196, a variable has to be protected by an
atomic statement "*if it is accessed from an async function*". But seems to
me, *"a"* is accessed from an async function in all 3 cases above and none
is protected except
*a = 0;*
in Timer.
Can anybody please share the experience on atomic? Thanks in advance.
--
-Xiaohui Liu
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help