On Fri, May 26, 2006 at 05:19:30AM -0700, Boldoo wrote: > Hi > > 1. Does any one could explain me purpose of > interval_outstanding variable in TimerM component? > When I look at Clock.fire event, then the HandleFire > task is only posted if interval_outstanding is equal > to zero. But I cannot understand how > interval_outstanding become zero.
It's set zero when the timer event is handled by HandleFire(). The code is atomic { int_out = interval_outstanding; interval_outstanding = 0; } The purpose is, I think, to synchronize the actions of the HandleFire task and the clock interrupts. Only when one HandleFire task finishes is another posted, hence avoiding task queue overflow or race conditions on mTimerList. I am just guessing, and the authors (Joe et al.) would have the ultimate authority explaining this. > 2. and why counter value is added to interval to > calculate remained ticks (mTimerList[id].ticksleft) in > command Timer.start? In my opinion to get the remained > ticks simply substract counter value from the interval > value, such as > remained ticks=interval - counter value This is also handled in HandleFire. The code reads if (mState&(0x1L<<i)) { mTimerList[i].ticksLeft -= int_out; Cheers, lin -- Lin Gu Department of Computer Science University of Virginia Tel: 434-825-3115 Web: http://www.cs.virginia.edu/~lg6e -------------------------------------- _______________________________________________ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help