⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

Scheduler

Struct Scheduler 

Source
pub struct Scheduler {
    pub current: Option<TaskPtr>,
    pub idle_task: Option<TaskPtr>,
    pub algorithm: SchedAlgorithm,
    pub preemption_enabled: AtomicBool,
    pub lock_count: AtomicU64,
    pub cpu_id: u8,
    pub cfs_queue: Option<Mutex<CfsRunQueue>>,
}
Expand description

Scheduler state

Fields§

§current: Option<TaskPtr>

Currently running task

§idle_task: Option<TaskPtr>

Idle task

§algorithm: SchedAlgorithm

Scheduling algorithm

§preemption_enabled: AtomicBool

Preemption enabled

§lock_count: AtomicU64

Scheduler lock count

§cpu_id: u8

CPU ID this scheduler is running on

§cfs_queue: Option<Mutex<CfsRunQueue>>

CFS run queue (if using CFS)

Implementations§

Source§

impl Scheduler

Source

pub const fn new() -> Self

Create new scheduler

Source

pub fn init(&mut self, idle_task: NonNull<Task>)

Initialize scheduler with idle task

Source

pub fn current(&self) -> Option<NonNull<Task>>

Get current task

Source

pub fn disable_preemption(&self)

Disable preemption

Source

pub fn enable_preemption(&self)

Enable preemption

Source

pub fn is_preemptible(&self) -> bool

Check if preemption is enabled

Source

pub fn enqueue(&self, task: NonNull<Task>)

Add task to ready queue

Source

pub fn pick_next(&self) -> Option<NonNull<Task>>

Select next task to run

Source

pub fn update_runtime(&self, task: NonNull<Task>, runtime: u64)

Update task runtime statistics

Source

pub fn tick(&mut self)

Handle timer tick

Source

pub fn schedule(&mut self)

Perform scheduling decision

Trait Implementations§

Source§

impl Default for Scheduler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for Scheduler

§

impl !RefUnwindSafe for Scheduler

§

impl Send for Scheduler

§

impl Sync for Scheduler

§

impl Unpin for Scheduler

§

impl !UnwindSafe for Scheduler

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.