Skip to main content

Scheduler

Struct Scheduler 

Source
pub struct Scheduler { /* private fields */ }
Expand description

The round-robin scheduler (per-CPU queues)

Implementations§

Source§

impl Scheduler

Source

pub fn new(cpu_count: usize) -> Self

Create a new scheduler instance

Source

pub fn add_task(&mut self, task: Arc<Task>) -> Option<usize>

Add a task to the scheduler

Source

pub fn add_task_with_parent( &mut self, task: Arc<Task>, parent: TaskId, ) -> Option<usize>

Performs the add task with parent operation.

Source

pub fn clear_task_wake_deadline_locked(&mut self, id: TaskId) -> bool

Performs the clear task wake deadline locked operation.

Source

pub fn set_task_wake_deadline_locked( &mut self, id: TaskId, deadline: u64, ) -> bool

Sets task wake deadline locked.

Source

pub fn wake_task_locked(&mut self, id: TaskId) -> (bool, Option<usize>)

Performs the wake task locked operation.

Returns (was_woken, ipi_cpu). The caller must send a resched IPI to ipi_cpu after releasing the scheduler lock.

Source

pub fn try_reap_child_locked( &mut self, parent: TaskId, target: Option<TaskId>, ) -> WaitChildResult

Attempts to reap child locked.

Source

pub fn pick_next_task(&mut self, cpu_index: usize) -> Arc<Task>

Pick the next task to run on cpu_index.

  1. Re-queues the current Running task (round-robin). The idle task is never re-queued — it is always available as the last-resort fallback. Keeping it out of the ready queue ensures the queue becomes truly empty when there is no real work, which lets work-stealing kick in on other CPUs.
  2. Pops from the local ready queue.
  3. Falls back to work-stealing from the busiest other CPU.
  4. Falls back to the per-CPU idle task.
Source

pub fn steal_task(&mut self, dst_cpu: usize, now_tick: u64) -> Option<Arc<Task>>

Try to steal one task from the most-loaded other CPU.

We steal from the back of the source queue (the task added most recently — least likely to have warm cache data on that CPU). We only steal when the source has ≥ 2 tasks, so it keeps at least one.

Source

pub fn migrate_ready_tasks_for_new_class_table(&mut self)

Performs the migrate ready tasks for new class table operation.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.