aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt/include/chvt.h
diff options
context:
space:
mode:
Diffstat (limited to 'os/rt/include/chvt.h')
-rw-r--r--os/rt/include/chvt.h11
1 files changed, 9 insertions, 2 deletions
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();