From c0e8496d234d2f3d19f8c3cdea491de478773f0a Mon Sep 17 00:00:00 2001 From: Leon Schuermann Date: Mon, 6 Jan 2025 06:02:00 -0500 Subject: [PATCH 1/3] litex/arty: use MLFQ scheduler by default --- boards/litex/arty/src/main.rs | 41 ++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/boards/litex/arty/src/main.rs b/boards/litex/arty/src/main.rs index 893d492f8d..0b14741b5c 100644 --- a/boards/litex/arty/src/main.rs +++ b/boards/litex/arty/src/main.rs @@ -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}; @@ -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, @@ -190,7 +201,18 @@ impl KernelResources; + type Scheduler = MLFQSched< + 'static, + VirtualMuxAlarm< + 'static, + litex_vexriscv::timer::LiteXAlarm< + 'static, + 'static, + socc::SoCRegisterFmt, + socc::ClockFrequency, + >, + >, + >; type SchedulerTimer = VirtualSchedulerTimer< VirtualMuxAlarm< 'static, @@ -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, From 45ef5b8d1355652f66506845a8c6280ab4619fa9 Mon Sep 17 00:00:00 2001 From: Leon Schuermann Date: Mon, 6 Jan 2025 06:02:05 -0500 Subject: [PATCH 2/3] litex/sim: use MLFQ scheduler by default --- boards/litex/sim/src/main.rs | 45 +++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/boards/litex/sim/src/main.rs b/boards/litex/sim/src/main.rs index 80bc40ae44..f2497bcc31 100644 --- a/boards/litex/sim/src/main.rs +++ b/boards/litex/sim/src/main.rs @@ -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}; @@ -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, @@ -189,7 +200,18 @@ impl KernelResources; + type Scheduler = MLFQSched< + 'static, + VirtualMuxAlarm< + 'static, + litex_vexriscv::timer::LiteXAlarm< + 'static, + 'static, + socc::SoCRegisterFmt, + socc::ClockFrequency, + >, + >, + >; type SchedulerTimer = VirtualSchedulerTimer< VirtualMuxAlarm< 'static, @@ -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, @@ -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, From dfda669d3af5825e47013b99cf2f27506133e814 Mon Sep 17 00:00:00 2001 From: Leon Schuermann Date: Mon, 6 Jan 2025 09:02:59 -0500 Subject: [PATCH 3/3] boards/litex/arty: fix process console start --- boards/litex/arty/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/litex/arty/src/main.rs b/boards/litex/arty/src/main.rs index 0b14741b5c..af37d10c84 100644 --- a/boards/litex/arty/src/main.rs +++ b/boards/litex/arty/src/main.rs @@ -627,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,