From 775ab02a91ab162685b34018357e6b3b9480b5c2 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Mon, 23 Mar 2015 10:28:44 +0000 Subject: Tentative fix for tickless mode. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7797 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/rt/include/chvt.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'os/rt/include') diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h index 1bc83d908..736d572b4 100644 --- a/os/rt/include/chvt.h +++ b/os/rt/include/chvt.h @@ -494,6 +494,15 @@ static inline void chVTDoTickI(void) { ch.vtlist.vt_next = vtp->vt_next; fn = vtp->vt_func; vtp->vt_func = NULL; + + /* If the list is empty then the timer is stopped.*/ + if (&ch.vtlist == (virtual_timers_list_t *)ch.vtlist.vt_next) { + port_timer_stop_alarm(); + } + + /* Leaving the system critical zone in order to execute the callback + and in order to give a preemption chance to higher priority + interrupts.*/ chSysUnlockFromISR(); /* The callback is invoked outside the kernel critical zone.*/ @@ -503,10 +512,11 @@ static inline void chVTDoTickI(void) { of the list.*/ chSysLockFromISR(); - /* Next element in the list, if the list is empty then ending the loop.*/ + /* If the list is empty then ending the loop, the list has to be + re-checked because new timers could have been added from within + the callback.*/ vtp = ch.vtlist.vt_next; if (&ch.vtlist == (virtual_timers_list_t *)vtp) { - port_timer_stop_alarm(); return; } -- cgit v1.2.3