Skip to content

Commit

Permalink
Merge pull request tock#4295 from lschuermann/dev/litex-mlfq-sched
Browse files Browse the repository at this point in the history
litex: use MLFQ scheduler by default
  • Loading branch information
bradjc authored Jan 6, 2025
2 parents b3412b4 + dfda669 commit 4b1f3eb
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 15 deletions.
43 changes: 36 additions & 7 deletions boards/litex/arty/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use kernel::hil::time::{Alarm, Timer};
use kernel::platform::chip::InterruptService;
use kernel::platform::scheduler_timer::VirtualSchedulerTimer;
use kernel::platform::{KernelResources, SyscallDriverLookup};
use kernel::scheduler::cooperative::CooperativeSched;
use kernel::scheduler::mlfq::MLFQSched;
use kernel::utilities::registers::interfaces::ReadWriteable;
use kernel::utilities::StaticRef;
use kernel::{create_capability, debug, static_init};
Expand Down Expand Up @@ -153,7 +153,18 @@ struct LiteXArty {
>,
>,
ipc: kernel::ipc::IPC<{ NUM_PROCS as u8 }>,
scheduler: &'static CooperativeSched<'static>,
scheduler: &'static MLFQSched<
'static,
VirtualMuxAlarm<
'static,
litex_vexriscv::timer::LiteXAlarm<
'static,
'static,
socc::SoCRegisterFmt,
socc::ClockFrequency,
>,
>,
>,
scheduler_timer: &'static VirtualSchedulerTimer<
VirtualMuxAlarm<
'static,
Expand Down Expand Up @@ -190,7 +201,18 @@ impl KernelResources<litex_vexriscv::chip::LiteXVexRiscv<LiteXArtyInterruptableP
type SyscallDriverLookup = Self;
type SyscallFilter = ();
type ProcessFault = ();
type Scheduler = CooperativeSched<'static>;
type Scheduler = MLFQSched<
'static,
VirtualMuxAlarm<
'static,
litex_vexriscv::timer::LiteXAlarm<
'static,
'static,
socc::SoCRegisterFmt,
socc::ClockFrequency,
>,
>,
>;
type SchedulerTimer = VirtualSchedulerTimer<
VirtualMuxAlarm<
'static,
Expand Down Expand Up @@ -579,9 +601,16 @@ unsafe fn start() -> (
)
.finalize(components::low_level_debug_component_static!());

let scheduler =
components::sched::cooperative::CooperativeComponent::new(&*addr_of!(PROCESSES))
.finalize(components::cooperative_component_static!(NUM_PROCS));
let scheduler = components::sched::mlfq::MLFQComponent::new(mux_alarm, &*addr_of!(PROCESSES))
.finalize(components::mlfq_component_static!(
litex_vexriscv::timer::LiteXAlarm<
'static,
'static,
socc::SoCRegisterFmt,
socc::ClockFrequency,
>,
NUM_PROCS
));

let litex_arty = LiteXArty {
console,
Expand All @@ -598,8 +627,8 @@ unsafe fn start() -> (
),
};

let _ = litex_arty.pconsole.start();
debug!("LiteX+VexRiscv on ArtyA7: initialization complete, entering main loop.");
let _ = litex_arty.pconsole.start();

kernel::process::load_processes(
board_kernel,
Expand Down
45 changes: 37 additions & 8 deletions boards/litex/sim/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use kernel::hil::time::{Alarm, Timer};
use kernel::platform::chip::InterruptService;
use kernel::platform::scheduler_timer::VirtualSchedulerTimer;
use kernel::platform::{KernelResources, SyscallDriverLookup};
use kernel::scheduler::cooperative::CooperativeSched;
use kernel::scheduler::mlfq::MLFQSched;
use kernel::utilities::registers::interfaces::ReadWriteable;
use kernel::utilities::StaticRef;
use kernel::{create_capability, debug, static_init};
Expand Down Expand Up @@ -150,7 +150,18 @@ struct LiteXSim {
>,
>,
ipc: kernel::ipc::IPC<{ NUM_PROCS as u8 }>,
scheduler: &'static CooperativeSched<'static>,
scheduler: &'static MLFQSched<
'static,
VirtualMuxAlarm<
'static,
litex_vexriscv::timer::LiteXAlarm<
'static,
'static,
socc::SoCRegisterFmt,
socc::ClockFrequency,
>,
>,
>,
scheduler_timer: &'static VirtualSchedulerTimer<
VirtualMuxAlarm<
'static,
Expand Down Expand Up @@ -189,7 +200,18 @@ impl KernelResources<litex_vexriscv::chip::LiteXVexRiscv<LiteXSimInterruptablePe
type SyscallDriverLookup = Self;
type SyscallFilter = ();
type ProcessFault = ();
type Scheduler = CooperativeSched<'static>;
type Scheduler = MLFQSched<
'static,
VirtualMuxAlarm<
'static,
litex_vexriscv::timer::LiteXAlarm<
'static,
'static,
socc::SoCRegisterFmt,
socc::ClockFrequency,
>,
>,
>;
type SchedulerTimer = VirtualSchedulerTimer<
VirtualMuxAlarm<
'static,
Expand Down Expand Up @@ -652,11 +674,16 @@ unsafe fn start() -> (
)
.finalize(components::low_level_debug_component_static!());

debug!("Verilated LiteX+VexRiscv: initialization complete, entering main loop.");

let scheduler =
components::sched::cooperative::CooperativeComponent::new(&*addr_of!(PROCESSES))
.finalize(components::cooperative_component_static!(NUM_PROCS));
let scheduler = components::sched::mlfq::MLFQComponent::new(mux_alarm, &*addr_of!(PROCESSES))
.finalize(components::mlfq_component_static!(
litex_vexriscv::timer::LiteXAlarm<
'static,
'static,
socc::SoCRegisterFmt,
socc::ClockFrequency,
>,
NUM_PROCS
));

let litex_sim = LiteXSim {
gpio_driver,
Expand All @@ -674,6 +701,8 @@ unsafe fn start() -> (
scheduler_timer,
};

debug!("Verilated LiteX+VexRiscv: initialization complete, entering main loop.");

kernel::process::load_processes(
board_kernel,
chip,
Expand Down

0 comments on commit 4b1f3eb

Please sign in to comment.