[Tinyos-help] Apparent Timing Bug in RssiSample
Tal Rusak
tr76 at cornell.edu
Sat Jan 12 18:27:44 PST 2008
Hi,
I have noticed an apparent bug the tinyos-2.x-contrib application
RssiSample. In
/tinyos-2.x-contrib/stanford-sing/apps/RssiSample/NoiseSampleP.nc, on
lines 197-201, the Alarm0.fired() even is implemented as follows:
197 async event void Alarm0.fired()
198 {
199 call Resource.request();
200 call Alarm0.start(ALARM_PERIOD);
201 }
I believe that calling Resource.request() before
Alarm0.start(ALARM_PERIOD) causes a time lag since the next alarm
does not start until after the call to Resource.request() returns.
There are two possible patches that I have come up with.
1) Switch the order of the calls, i.e.,
197 async event void Alarm0.fired()
198 {
199 call Alarm0.start(ALARM_PERIOD);
200 call Resource.request();
201 }
It may be the case that this introduces a race condition.
2) Use a periodic timer (see attached code).
I have audited collection time for 61440 samples (1 minute clock
time) for each of the approaches with the following results (four
runs of each):
Original
000:01:08.593
000:01:08.730
000:01:08.781
000:01:08.699
Swapped calls (correction 1)
000:01:03.311
000:01:03.229
000:01:03.193
000:01:03.339
Periodic Timer (correction 2)
000:01:00.238
000:01:00.250
000:01:00.324
000:01:00.255
These results were collected using the stopwatch program
(http://expect.nist.gov/stopwatch/) by looking at the LEDs on a telosb mote.
Thanks,
Tal
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NoiseSampleP.nc
Type: application/x-netcdf
Size: 7351 bytes
Desc: not available
Url : https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20080112/ee83c154/NoiseSampleP-0001.nc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NoiseSample.h
Type: text/x-chdr
Size: 502 bytes
Desc: not available
Url : https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20080112/ee83c154/NoiseSample-0001.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NoiseAppC.nc
Type: application/x-netcdf
Size: 2506 bytes
Desc: not available
Url : https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20080112/ee83c154/NoiseAppC-0001.nc
More information about the Tinyos-help
mailing list