Menu

#255 AlarmToTimerC possible unstoppable periodic timer

open
nobody
5
2012-12-12
2008-10-29
Anonymous
No

It seems possible that once a periodic timer has been started in an AlarmToTimerC component (lib/timer/AlarmToTimerC.nc), it might not get stopped by calls to Timer.stop. This situation is likely to be sporadic, since it would only occur if there is already a fired() task in the queue when Timer.stop is called. The fired() task does not currently check to see if the timer has been stopped before starting a new alarm:

task void fired()
{
if(m_oneshot == FALSE)
start(call Alarm.getAlarm(), m_dt, FALSE);
signal Timer.fired();
}

At present, this probably isn't a major problem, since all of the consumers of AlarmToTimerC access it through a virutalization layer that does properly handle stopping of periodic timers. However, it might be a good idea to fix this issue just in case someone decides to use AlarmToTimerC directly. The simplest fix is probably to amend Timer.stop() so that in addition to stopping the current alarm it also sets m_oneshot to TRUE. A slightly clearer modification (at the cost of some extra memory) would be to add a timer state variable that checks whether or not the timer is currently active.

Discussion