1 use super::Scheduler; 2 3 pub struct IdleScheduler; 4 5 impl Scheduler for IdleScheduler { 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 14 fn dequeue( 15 _rq: &mut super::CpuRunQueue, 16 _pcb: alloc::sync::Arc<crate::process::ProcessControlBlock>, 17 _flags: super::DequeueFlag, 18 ) { 19 } 20 21 fn yield_task(_rq: &mut super::CpuRunQueue) {} 22 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 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 /// 主要做一些统计工作 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 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 57 fn task_fork(_pcb: alloc::sync::Arc<crate::process::ProcessControlBlock>) { 58 todo!() 59 } 60 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