Skip to content
Snippets Groups Projects
Commit e7376e09 authored by Stefan Lankes's avatar Stefan Lankes Committed by Stefan Lankes
Browse files

disable timer if no task is waiting for a timer

parent 2219879b
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ use crate::scheduler::CoreId;
use alloc::collections::{LinkedList, VecDeque};
use alloc::rc::Rc;
use core::cell::RefCell;
use core::cmp::Ordering;
use core::convert::TryInto;
use core::fmt;
use core::num::NonZeroU64;
......@@ -129,6 +130,26 @@ impl TaskHandle {
}
}
impl Ord for TaskHandle {
fn cmp(&self, other: &Self) -> Ordering {
self.id.cmp(&other.id)
}
}
impl PartialOrd for TaskHandle {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl PartialEq for TaskHandle {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}
impl Eq for TaskHandle {}
/// Realize a priority queue for task handles
pub struct TaskHandlePriorityQueue {
queues: [Option<VecDeque<TaskHandle>>; NO_PRIORITIES],
......@@ -567,6 +588,9 @@ impl BlockedTaskQueue {
if first_task {
if let Some(next_node) = cursor.current() {
arch::set_oneshot_timer(next_node.wakeup_time);
} else {
// if no task is available, we have to disable the timer
arch::set_oneshot_timer(None);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment