[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/timer
TransformAlarmCounterC.nc, 1.3, 1.4
David Gay
idgay at users.sourceforge.net
Fri Aug 11 14:03:54 PDT 2006
Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/timer
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv22670
Modified Files:
TransformAlarmCounterC.nc
Log Message:
simplify logic
Index: TransformAlarmCounterC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/timer/TransformAlarmCounterC.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TransformAlarmCounterC.nc 10 Aug 2006 00:05:25 -0000 1.3
--- TransformAlarmCounterC.nc 11 Aug 2006 21:03:52 -0000 1.4
***************
*** 147,151 ****
atomic
{
-
m_upper++;
if ((m_upper & OVERFLOW_MASK) == 0)
--- 147,150 ----
***************
*** 179,207 ****
void set_alarm()
{
! to_size_type now = call Counter.get(), expires, remaining;
!
! /* m_t0 is assumed to be in the past. If it's > now, we assume
! that time has wrapped around */
!
! expires = m_t0 + m_dt;
!
! /* The cast is necessary to get correct wrap-around arithmetic */
! remaining = (to_size_type)(expires - now);
! /* if (expires <= now) remaining = 0; in wrap-around arithmetic */
! if (m_t0 <= now)
! {
! if (expires >= m_t0 && // if it wraps, it's > now
! expires <= now)
! remaining = 0;
! }
else
! {
! if (expires >= m_t0 || // didn't wrap so < now
! expires <= now)
! remaining = 0;
! }
! if (remaining > MAX_DELAY * 2)
{
if (remaining >= MAX_DELAY * 2 * (to_size_type)256)
--- 178,198 ----
void set_alarm()
{
! to_size_type now = call Counter.get(), elapsed = now - m_t0, remaining;
! m_skip_overflows = 0;
! if (elapsed >= m_dt)
! {
! remaining = 0;
! m_t0 += m_dt;
! m_dt = 0;
! }
else
! {
! remaining = m_dt - elapsed;
! /* MAX_DELAY is 1/2 an underlying counter overflow time. Just count
! overflows if the timer is far in the future, and we'll set an
! alarm once we're close to the deadline. */
! if (remaining > MAX_DELAY * 2)
{
if (remaining >= MAX_DELAY * 2 * (to_size_type)256)
***************
*** 211,218 ****
return;
}
- else
- m_skip_overflows = 0;
! if (remaining > MAX_DELAY)
{
m_t0 = now + MAX_DELAY;
--- 202,207 ----
return;
}
! if (remaining > MAX_DELAY)
{
m_t0 = now + MAX_DELAY;
***************
*** 220,228 ****
remaining = MAX_DELAY;
}
! else
{
m_t0 += m_dt;
m_dt = 0;
}
call AlarmFrom.startAt((from_size_type)now << bit_shift_right,
(from_size_type)remaining << bit_shift_right);
--- 209,218 ----
remaining = MAX_DELAY;
}
! else
{
m_t0 += m_dt;
m_dt = 0;
}
+ }
call AlarmFrom.startAt((from_size_type)now << bit_shift_right,
(from_size_type)remaining << bit_shift_right);
More information about the Tinyos-2-commits
mailing list