1 use super::Scheduler; 2 3 pub struct IdleScheduler; 4 5 impl Scheduler for IdleScheduler { enqueue( _rq: &mut super::CpuRunQueue, _pcb: alloc::sync::Arc<crate::process::ProcessControlBlock>, _flags: super::EnqueueFlag, )6 fn enqueue( 7 _rq: &mut super::CpuRunQueue, 8 _pcb: alloc::sync::Arc<crate::process::ProcessControlBlock>, 9 _flags: super::EnqueueFlag, 10 ) { 11 // idle已经被设置,无需入队 12 } 13 dequeue( _rq: &mut super::CpuRunQueue, _pcb: alloc::sync::Arc<crate::process::ProcessControlBlock>, _flags: super::DequeueFlag, )14 fn dequeue( 15 _rq: &mut super::CpuRunQueue, 16 _pcb: alloc::sync::Arc<crate::process::ProcessControlBlock>, 17 _flags: super::DequeueFlag, 18 ) { 19 } 20 yield_task(_rq: &mut super::CpuRunQueue)21 fn yield_task(_rq: &mut super::CpuRunQueue) {} 22 check_preempt_currnet( rq: &mut super::CpuRunQueue, _pcb: &alloc::sync::Arc<crate::process::ProcessControlBlock>, _flags: super::WakeupFlags, )23 fn check_preempt_currnet( 24 rq: &mut super::CpuRunQueue, 25 _pcb: &alloc::sync::Arc<crate::process::ProcessControlBlock>, 26 _flags: super::WakeupFlags, 27 ) { 28 rq.resched_current(); 29 } 30 pick_task( _rq: &mut super::CpuRunQueue, ) -> Option<alloc::sync::Arc<crate::process::ProcessControlBlock>>31 fn pick_task( 32 _rq: &mut super::CpuRunQueue, 33 ) -> Option<alloc::sync::Arc<crate::process::ProcessControlBlock>> { 34 panic!() 35 } 36 37 /// ### 表示idle被选中 38 /// 39 /// 主要做一些统计工作 pick_next_task( _rq: &mut super::CpuRunQueue, _pcb: Option<alloc::sync::Arc<crate::process::ProcessControlBlock>>, ) -> Option<alloc::sync::Arc<crate::process::ProcessControlBlock>>40 fn pick_next_task( 41 _rq: &mut super::CpuRunQueue, 42 _pcb: Option<alloc::sync::Arc<crate::process::ProcessControlBlock>>, 43 ) -> Option<alloc::sync::Arc<crate::process::ProcessControlBlock>> { 44 // TODO: Fixme 45 // 做一些统计工作 46 None 47 } 48 tick( _rq: &mut super::CpuRunQueue, _pcb: alloc::sync::Arc<crate::process::ProcessControlBlock>, _queued: bool, )49 fn tick( 50 _rq: &mut super::CpuRunQueue, 51 _pcb: alloc::sync::Arc<crate::process::ProcessControlBlock>, 52 _queued: bool, 53 ) { 54 // Nothing to do 55 } 56 task_fork(_pcb: alloc::sync::Arc<crate::process::ProcessControlBlock>)57 fn task_fork(_pcb: alloc::sync::Arc<crate::process::ProcessControlBlock>) { 58 todo!() 59 } 60 put_prev_task( _rq: &mut super::CpuRunQueue, _prev: alloc::sync::Arc<crate::process::ProcessControlBlock>, )61 fn put_prev_task( 62 _rq: &mut super::CpuRunQueue, 63 _prev: alloc::sync::Arc<crate::process::ProcessControlBlock>, 64 ) { 65 // Nothing todo 66 } 67 } 68