Struct scheduler::RRScheduler
source · pub struct RRScheduler<T, const MAX_TIME_SLICE: usize> { /* private fields */ }
Expand description
A simple Round-Robin (RR) preemptive scheduler.
It’s very similar to the FifoScheduler
, but every task has a time slice
counter that is decremented each time a timer tick occurs. When the current
task’s time slice counter reaches zero, the task is preempted and needs to
be rescheduled.
Unlike FifoScheduler
, it uses VecDeque
as the ready queue. So it may
take O(n) time to remove a task from the ready queue.
Implementations§
source§impl<T, const S: usize> RRScheduler<T, S>
impl<T, const S: usize> RRScheduler<T, S>
sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new empty RRScheduler
.
sourcepub fn scheduler_name() -> &'static str
pub fn scheduler_name() -> &'static str
get the name of scheduler
Trait Implementations§
source§impl<T, const S: usize> BaseScheduler for RRScheduler<T, S>
impl<T, const S: usize> BaseScheduler for RRScheduler<T, S>
source§fn remove_task(&mut self, task: &Self::SchedItem) -> Option<Self::SchedItem>
fn remove_task(&mut self, task: &Self::SchedItem) -> Option<Self::SchedItem>
Removes a task by its reference from the scheduler. Returns the owned
removed task with ownership if it exists. Read more
source§fn pick_next_task(&mut self) -> Option<Self::SchedItem>
fn pick_next_task(&mut self) -> Option<Self::SchedItem>
Picks the next task to run, it will be removed from the scheduler.
Returns
None
if there is not runnable task.source§fn put_prev_task(&mut self, prev: Self::SchedItem, preempt: bool)
fn put_prev_task(&mut self, prev: Self::SchedItem, preempt: bool)
Puts the previous task back to the scheduler. The previous task is
usually placed at the end of the ready queue, making it less likely
to be re-scheduled. Read more
Auto Trait Implementations§
impl<T, const MAX_TIME_SLICE: usize> RefUnwindSafe for RRScheduler<T, MAX_TIME_SLICE>where
T: RefUnwindSafe,
impl<T, const MAX_TIME_SLICE: usize> Send for RRScheduler<T, MAX_TIME_SLICE>
impl<T, const MAX_TIME_SLICE: usize> Sync for RRScheduler<T, MAX_TIME_SLICE>
impl<T, const MAX_TIME_SLICE: usize> Unpin for RRScheduler<T, MAX_TIME_SLICE>
impl<T, const MAX_TIME_SLICE: usize> UnwindSafe for RRScheduler<T, MAX_TIME_SLICE>where
T: RefUnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more