summaryrefslogtreecommitdiff
path: root/nuttx/sched/wdog
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-08-11 08:25:25 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-08-11 08:25:25 -0600
commit0dd76647a0332aac2d38631c9464336d30910b5c (patch)
tree223309e0215e8a9f586bcf373a75932709c792f4 /nuttx/sched/wdog
parentc9ff241626b21a98cef543a03444fd1cf1e5e11b (diff)
downloadpx4-nuttx-0dd76647a0332aac2d38631c9464336d30910b5c.tar.gz
px4-nuttx-0dd76647a0332aac2d38631c9464336d30910b5c.tar.bz2
px4-nuttx-0dd76647a0332aac2d38631c9464336d30910b5c.zip
Timers: In Tickless mode, need to stop the interval timer before inserted a new delay into the timer list. Otherwise, the time is incorrect on the first entry of the list
Diffstat (limited to 'nuttx/sched/wdog')
-rw-r--r--nuttx/sched/wdog/wd_start.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/nuttx/sched/wdog/wd_start.c b/nuttx/sched/wdog/wd_start.c
index 8488eb898..6ba19da39 100644
--- a/nuttx/sched/wdog/wd_start.c
+++ b/nuttx/sched/wdog/wd_start.c
@@ -233,9 +233,6 @@ int wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry, int argc, ...)
FAR wdog_t *next;
int32_t now;
irqstate_t saved_state;
-#ifdef CONFIG_SCHED_TICKLESS
- bool reassess = false;
-#endif
int i;
/* Verify the wdog */
@@ -288,6 +285,16 @@ int wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry, int argc, ...)
delay--;
}
+#ifdef CONFIG_SCHED_TICKLESS
+ /* Cancel the interval timer that drives the timing events. This will cause
+ * wd_timer to be called which update the delay value for the first time
+ * at the head of the timer list (there is a possibility that it could even
+ * remove it).
+ */
+
+ (void)sched_timer_cancel();
+#endif
+
/* Do the easy case first -- when the watchdog timer queue is empty. */
if (g_wdactivelist.head == NULL)
@@ -295,14 +302,6 @@ int wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry, int argc, ...)
/* Add the watchdog to the head == tail of the queue. */
sq_addlast((FAR sq_entry_t*)wdog, &g_wdactivelist);
-
-#ifdef CONFIG_SCHED_TICKLESS
- /* Whenever the watchdog at the head of the queue changes, then we
- * need to reassess the interval timer setting.
- */
-
- reassess = true;
-#endif
}
/* There are other active watchdogs in the timer queue */
@@ -348,14 +347,6 @@ int wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry, int argc, ...)
/* Insert the watchdog at the head of the list */
sq_addfirst((FAR sq_entry_t*)wdog, &g_wdactivelist);
-
-#ifdef CONFIG_SCHED_TICKLESS
- /* If the watchdog at the head of the queue changes, then we
- * need to reassess the interval timer setting.
- */
-
- reassess = true;
-#endif
}
else
{
@@ -395,17 +386,12 @@ int wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry, int argc, ...)
wdog->active = true;
#ifdef CONFIG_SCHED_TICKLESS
- /* Reassess the interval timer that will generate the next interval event.
- * In many cases, this will be unnecessary: This is really only necessary
- * when the watchdog timer at the head of the queue is change. If the
- * timer is inserted later in the queue then the timer at the head is
- * unchanged.
+ /* Resume the interval timer that will generate the next interval event.
+ * If the timer at the head of the list changed, then this will pick that
+ * new delay.
*/
- if (reassess)
- {
- sched_timer_reassess();
- }
+ sched_timer_resume();
#endif
irqrestore(saved_state);