From fef738e832e3d16009ce9b33d1918e131ff9a8cf Mon Sep 17 00:00:00 2001 From: Maciej Pasternacki Date: Mon, 18 Nov 2019 16:03:15 +0100 Subject: [PATCH] TimerQueue.dequeue: don't set SYST reload to 0 ARM Architecture Reference Manual says: "Setting SYST_RVR to zero has the effect of disabling the SysTick counter independently of the counter enable bit." If Monotonic's ratio is less than one, the timeout calculations can compute zero if next task is scheduled after current instant, but before next timer tick. This results in disabling SYST and freezing the timer queue. --- src/tq.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tq.rs b/src/tq.rs index 4edb40a7fe..21beeb9cff 100644 --- a/src/tq.rs +++ b/src/tq.rs @@ -68,6 +68,13 @@ where .map(|x| x / ratio.denominator) }) { None => MAX, + + // ARM Architecture Reference Manual says: + // "Setting SYST_RVR to zero has the effect of + // disabling the SysTick counter independently + // of the counter enable bit." + Some(0) => 1, + Some(x) => cmp::min(MAX, x), }; mem::transmute::<_, SYST>(()).set_reload(dur);