RRScheduler

Struct RRScheduler 

Source
pub struct RRScheduler {
    run_queue: TaskQueue,
    time_slice: usize,
    current_slice: usize,
}
Expand description

简单的轮转调度器实现 每个任务按顺序轮流获得 CPU 时间片 约束:

  1. 要求开始调度后任何时刻,至少有一个任务处于运行状态

Fields§

§run_queue: TaskQueue§time_slice: usize§current_slice: usize

Implementations§

Source§

impl RRScheduler

Source

pub fn update_time_slice(&mut self) -> bool

更新当前时间片计数器

§返回值

如果时间片用尽,返回 true;否则返回 false

Trait Implementations§

Source§

impl Scheduler for RRScheduler

Source§

fn new() -> Self

构造函数
Source§

fn next_task(&mut self) -> Option<SwitchPlan>

选择下一个要运行的任务 Read more
Source§

fn add_task(&mut self, task: Arc<SpinLock<Task>>)

添加任务到调度器 参数: Read more
Source§

fn sleep_task(&mut self, task: Arc<SpinLock<Task>>, receive_signal: bool)

任务阻塞 修改任务状态并从运行队列中移除 参数: Read more
Source§

fn wake_up(&mut self, task: Arc<SpinLock<Task>>)

唤醒任务 修改任务状态并将其添加到运行队列 参数: Read more
Source§

fn exit_task(&mut self, task: Arc<SpinLock<Task>>)

任务终止 修改任务状态并从调度器中移除 参数: Read more
Source§

fn sleep_task_with_guard( &mut self, task: &mut SpinLockGuard<'_, TaskStruct>, stask: Arc<SpinLock<Task>>, receive_signal: bool, )

带保护地阻塞任务 修改任务状态并从运行队列中移除 参数: Read more

Auto Trait Implementations§

§

impl Freeze for RRScheduler

§

impl !RefUnwindSafe for RRScheduler

§

impl Send for RRScheduler

§

impl Sync for RRScheduler

§

impl Unpin for RRScheduler

§

impl !UnwindSafe for RRScheduler

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.