#![cfg_attr(not(test), no_std)]
#![feature(unsafe_cell_access)]
use config::RQ_CAP;
#[cfg(any(test, feature = "alloc"))]
extern crate alloc;
mod percpu;
pub use percpu::*;
cfg_if::cfg_if! {
if #[cfg(feature = "sched-rr")] {
mod round_robin;
const MAX_TIME_SLICE: usize = 5;
pub type BaseTask<T> = round_robin::RRTask<T, MAX_TIME_SLICE>;
pub type BaseTaskRef<T> = round_robin::RRTaskRef<T, MAX_TIME_SLICE>;
pub type Scheduler<T> = round_robin::RRScheduler<T, MAX_TIME_SLICE, RQ_CAP>;
} else if #[cfg(feature = "sched-cfs")] {
mod cfs;
pub type BaseTask<T> = cfs::CFSTask<T>;
pub type BaseTaskRef<T> = cfs::CFSTaskRef<T>;
pub type Scheduler<T> = cfs::CFScheduler<T, RQ_CAP>;
} else {
mod fifo;
pub type BaseTask<T> = fifo::FifoTask<T>;
pub type BaseTaskRef<T> = fifo::FiFoTaskRef<T>;
pub type Scheduler<T> = fifo::FifoScheduler<T, RQ_CAP>;
}
}
pub trait BaseScheduler {
type SchedItem;
fn init(&mut self);
fn add_task(&self, task: Self::SchedItem);
fn pick_next_task(&self) -> Option<Self::SchedItem>;
fn put_prev_task(&self, prev: Self::SchedItem, preempt: bool);
fn task_tick(&self, current: &Self::SchedItem) -> bool;
fn set_priority(&self, task: &Self::SchedItem, prio: isize) -> bool;
}