use crate::task::Task; use alloc::{collections::VecDeque, sync::Arc}; use eonix_sync::Spin; #[eonix_percpu::define_percpu_shared] static READYQUEUE: Spin = Spin::new(FifoReadyQueue::new()); pub trait ReadyQueue { fn get(&mut self) -> Option>; fn put(&mut self, thread: Arc); } pub struct FifoReadyQueue { threads: VecDeque>, } impl FifoReadyQueue { pub const fn new() -> Self { FifoReadyQueue { threads: VecDeque::new(), } } } impl ReadyQueue for FifoReadyQueue { fn get(&mut self) -> Option> { self.threads.pop_front() } fn put(&mut self, thread: Arc) { self.threads.push_back(thread); } } pub fn local_rq() -> &'static Spin { &*READYQUEUE } pub fn cpu_rq(cpuid: usize) -> &'static Spin { READYQUEUE.get_for_cpu(cpuid).expect("CPU not found") }