From 5b59f89d98bc8d4ae1a7269ab1e09a6d8f649d2f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 30 Nov 2014 10:09:38 +0000 Subject: [PATCH] Removed assertion for repeated tickless timer stop. Improved comments in virtual timers. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7550 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/src/st.c | 2 -- os/rt/include/chvt.h | 11 +++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/os/hal/src/st.c b/os/hal/src/st.c index 17abecd71..9f067cfeb 100644 --- a/os/hal/src/st.c +++ b/os/hal/src/st.c @@ -94,8 +94,6 @@ void stStartAlarm(systime_t time) { */ void stStopAlarm(void) { - osalDbgAssert(stIsAlarmActive() != false, "not active"); - st_lld_stop_alarm(); } diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h index 754483649..9538474c9 100644 --- a/os/rt/include/chvt.h +++ b/os/rt/include/chvt.h @@ -468,12 +468,19 @@ static inline void chVTDoTickI(void) { systime_t delta = now - ch.vtlist.vt_lasttime; while ((vtp = ch.vtlist.vt_next)->vt_delta <= delta) { + vtfunc_t fn; + + /* The "last time" becomes this timer's expiration time.*/ delta -= vtp->vt_delta; ch.vtlist.vt_lasttime += vtp->vt_delta; - vtfunc_t fn = vtp->vt_func; - vtp->vt_func = (vtfunc_t)NULL; + + /* The timer is removed from the list and marked as non-armed.*/ vtp->vt_next->vt_prev = (virtual_timer_t *)&ch.vtlist; ch.vtlist.vt_next = vtp->vt_next; + fn = vtp->vt_func; + vtp->vt_func = (vtfunc_t)NULL; + + /* The callback is invoked outside the kernel critical zone.*/ chSysUnlockFromISR(); fn(vtp->vt_par); chSysLockFromISR();