pub struct RRScheduler {
run_queue: TaskQueue,
time_slice: usize,
current_slice: usize,
}Expand description
简单的轮转调度器实现 每个任务按顺序轮流获得 CPU 时间片 约束:
- 要求开始调度后任何时刻,至少有一个任务处于运行状态
Fields§
§run_queue: TaskQueue§time_slice: usize§current_slice: usizeImplementations§
Source§impl RRScheduler
impl RRScheduler
Sourcepub fn update_time_slice(&mut self) -> bool
pub fn update_time_slice(&mut self) -> bool
Trait Implementations§
Source§impl Scheduler for RRScheduler
impl Scheduler for RRScheduler
Source§fn next_task(&mut self) -> Option<SwitchPlan>
fn next_task(&mut self) -> Option<SwitchPlan>
选择下一个要运行的任务 Read more
Source§fn sleep_task(&mut self, task: Arc<SpinLock<Task>>, receive_signal: bool)
fn sleep_task(&mut self, task: Arc<SpinLock<Task>>, receive_signal: bool)
任务阻塞
修改任务状态并从运行队列中移除
参数: Read more
Source§fn sleep_task_with_guard(
&mut self,
task: &mut SpinLockGuard<'_, TaskStruct>,
stask: Arc<SpinLock<Task>>,
receive_signal: bool,
)
fn sleep_task_with_guard( &mut self, task: &mut SpinLockGuard<'_, TaskStruct>, stask: Arc<SpinLock<Task>>, receive_signal: bool, )
带保护地阻塞任务
修改任务状态并从运行队列中移除
参数: Read more