macro_rules! main {
($about:expr) => { ... };
($about:expr, $opts:ty) => { ... };
}Expand description
The main() of a scheduler: the objects its build script left in
OUT_DIR, loaded and run by cli(). The scheduler’s options are a
clap::Args structure, each field named as the tunable it sets, a
time in microseconds as the tunable in nanoseconds, and what else the scheduler adds to the loader is its Scheduler
implementation:
ⓘ
#[derive(clap::Args)]
struct Opts {
/// Scheduling slice duration in microseconds.
#[clap(short = 's', long, default_value = "5000")]
slice_us: u64,
}
impl scx_rustsched_loader::Scheduler for Opts {}
scx_rustsched_loader::main!("A minimal sched_ext scheduler written in Rust BPF", Opts);An option that is not the tunable’s value as it stands, such as a
list of CPUs that the scheduler takes as a mask, has a name of its
own, and Scheduler::settings() sets the tunable from it:
ⓘ
impl scx_rustsched_loader::Scheduler for Opts {
fn settings(
&self,
params: &mut scx_rustsched_loader::Params,
) -> scx_rustsched_loader::Result<()> {
params.set("primary_cpus", &mask_of(&self.primary_domain)?)
}
}Every tunable of the scheduler has to be set by one or the other.