536: Fix a bug in the timer queue due to comparison bug in embedded-time r=AfoHT a=korken89



Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
This commit is contained in:
bors[bot] 2021-09-27 13:43:32 +00:00 committed by GitHub
commit e6c5244e7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -111,7 +111,9 @@ where
mono.clear_compare_flag(); mono.clear_compare_flag();
if let Some(instant) = self.0.peek().map(|p| p.instant) { if let Some(instant) = self.0.peek().map(|p| p.instant) {
if instant <= unwrapper(Clock::try_now(mono)) { let now = unwrapper(Clock::try_now(mono));
// This if statement is like this and not <= due to a bug in embedded-time
if instant < now || instant == now {
// task became ready // task became ready
let nr = unsafe { self.0.pop_unchecked() }; let nr = unsafe { self.0.pop_unchecked() };
@ -124,7 +126,8 @@ where
// dequeue. If the monotonic is fast enough it can happen that from the // dequeue. If the monotonic is fast enough it can happen that from the
// read of now to the set of the compare, the time can overflow. This is to // read of now to the set of the compare, the time can overflow. This is to
// guard against this. // guard against this.
if instant <= unwrapper(Clock::try_now(mono)) { let now = unwrapper(Clock::try_now(mono));
if instant < now || instant == now {
let nr = unsafe { self.0.pop_unchecked() }; let nr = unsafe { self.0.pop_unchecked() };
Some((nr.task, nr.index)) Some((nr.task, nr.index))