[Tinyos-devel] Bug in timer system

David Gay dgay42 at gmail.com
Wed Mar 5 08:55:33 PST 2008


On Tue, Mar 4, 2008 at 11:12 AM, Cory Sharp <cory at sentilla.com> wrote:
>  // Calculate "remaining" before the timer is fired. If a timer
>  // restarts itself in a fired event, then we 1) need a consistent
>  // "remaining" value to work with, and no worries because 2) all
>
>  // start commands post executeTimersNow, so the timer will be
>  // recomputed later, anyway.
>
>  int32_t elapsed = then - timer->t0;
>  int32_t remaining = timer->dt - elapsed;
>  bool compute_min_remaining = TRUE;
>
>
>  // If the elapsed time is negative, then t0 is in the future, so
>  // don't process it. This implies:
>  // 1) t0 in the future is okay
>  // 2) dt can be at most maxval(uint32_t)/2
>
>  if ((elapsed >= 0) && (timer->dt <= (uint32_t)elapsed))

The problem with this approach is that t0 is, by definition of the
Timer interface, always in the past (wrap-around support).

David


More information about the Tinyos-devel mailing list