Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions boards/apollo3/lora_things_plus/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ use kernel::hil::spi::SpiMaster;
use kernel::hil::time::Counter;
use kernel::platform::{KernelResources, SyscallDriverLookup};
use kernel::process::ProcessArray;
use kernel::scheduler::round_robin::RoundRobinSched;
use kernel::{create_capability, debug, static_init};

#[cfg(feature = "atecc508a")]
Expand Down Expand Up @@ -149,6 +148,8 @@ type SignatureVerifyInMemoryKeys =
64,
>;

type SchedulerObj = components::sched::round_robin::RoundRobinComponentType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bike-shedding the name for this:

  • It's not an object. Arguably Rust doesn't have objects at all, and this is certainly is not one.
  • SchedulerType?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously, this would apply to all the boards and is hopefully just sed -i 's/type SchedulerObj/type SchedulerType/' boards/**/main.rs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like "Type" because everything is a type.

Here is what has emerged so far:

  • Hw: For types which are the specific hardware for a resource/hil. Example: type AlarmHw = nrf52840::nrf5x::rtc.
  • Driver: For types which are syscall drivers. Example: type AlarmDriver = capsules_core::alarm::Alarm.

I think for both of those, type would be suitable, ie AlarmType and then AlarmType again.

I think we would benefit from a class that has a generic feel. Any ideas other than "type"? I used obj only because it was something to use and easy to replace later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps something that helps with the semantic implications here, SchedulerChosen (SchedulerUsed, SchedulerSelected, ...)? i.e., you pass the scheduler you chose (in the same way that you pass the HW you instantiate) to generic Scheduler interfaces?


/// A structure representing this platform that holds references to all
/// capsules for this platform.
struct LoRaThingsPlus {
Expand Down Expand Up @@ -194,7 +195,7 @@ struct LoRaThingsPlus {
>,
>,
>,
scheduler: &'static RoundRobinSched<'static>,
scheduler: &'static SchedulerObj,
systick: cortexm4::systick::SysTick,
kv_driver: &'static capsules_extra::kv_driver::KVStoreDriver<
'static,
Expand Down Expand Up @@ -377,7 +378,7 @@ impl KernelResources<apollo3::chip::Apollo3<Apollo3DefaultPeripherals>> for LoRa
type SyscallDriverLookup = Self;
type SyscallFilter = ();
type ProcessFault = ();
type Scheduler = RoundRobinSched<'static>;
type Scheduler = SchedulerObj;
type SchedulerTimer = cortexm4::systick::SysTick;
type WatchDog = ();
type ContextSwitchCallback = ();
Expand Down
7 changes: 4 additions & 3 deletions boards/apollo3/redboard_artemis_atp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use kernel::hil::led::LedHigh;
use kernel::hil::time::Counter;
use kernel::platform::{KernelResources, SyscallDriverLookup};
use kernel::process::ProcessArray;
use kernel::scheduler::round_robin::RoundRobinSched;
use kernel::{create_capability, debug, static_init};

/// Support routines for debugging I/O.
Expand Down Expand Up @@ -69,6 +68,8 @@ static mut ALARM: Option<&'static MuxAlarm<'static, apollo3::stimer::STimer<'sta

kernel::stack_size! {0x1000}

type SchedulerObj = components::sched::round_robin::RoundRobinComponentType;

/// A structure representing this platform that holds references to all
/// capsules for this platform.
struct RedboardArtemisAtp {
Expand Down Expand Up @@ -103,7 +104,7 @@ struct RedboardArtemisAtp {
apollo3::ble::Ble<'static>,
VirtualMuxAlarm<'static, apollo3::stimer::STimer<'static>>,
>,
scheduler: &'static RoundRobinSched<'static>,
scheduler: &'static SchedulerObj,
systick: cortexm4::systick::SysTick,
}

Expand All @@ -130,7 +131,7 @@ impl KernelResources<apollo3::chip::Apollo3<Apollo3DefaultPeripherals>> for Redb
type SyscallDriverLookup = Self;
type SyscallFilter = ();
type ProcessFault = ();
type Scheduler = RoundRobinSched<'static>;
type Scheduler = SchedulerObj;
type SchedulerTimer = cortexm4::systick::SysTick;
type WatchDog = ();
type ContextSwitchCallback = ();
Expand Down
6 changes: 3 additions & 3 deletions boards/apollo3/redboard_artemis_nano/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use kernel::hil::led::LedHigh;
use kernel::hil::time::Counter;
use kernel::platform::{KernelResources, SyscallDriverLookup};
use kernel::process::ProcessArray;
use kernel::scheduler::round_robin::RoundRobinSched;
use kernel::{create_capability, debug, static_init};

/// Support routines for debugging I/O.
Expand Down Expand Up @@ -82,6 +81,7 @@ type BME280Sensor = components::bme280::Bme280ComponentType<
>;
type TemperatureDriver = components::temperature::TemperatureComponentType<BME280Sensor>;
type HumidityDriver = components::humidity::HumidityComponentType<BME280Sensor>;
type SchedulerObj = components::sched::round_robin::RoundRobinComponentType;

/// A structure representing this platform that holds references to all
/// capsules for this platform.
Expand Down Expand Up @@ -114,7 +114,7 @@ struct RedboardArtemisNano {
temperature: &'static TemperatureDriver,
humidity: &'static HumidityDriver,
air_quality: &'static capsules_extra::air_quality::AirQualitySensor<'static>,
scheduler: &'static RoundRobinSched<'static>,
scheduler: &'static SchedulerObj,
systick: cortexm4::systick::SysTick,
}

Expand Down Expand Up @@ -144,7 +144,7 @@ impl KernelResources<apollo3::chip::Apollo3<Apollo3DefaultPeripherals>> for Redb
type SyscallDriverLookup = Self;
type SyscallFilter = ();
type ProcessFault = ();
type Scheduler = RoundRobinSched<'static>;
type Scheduler = SchedulerObj;
type SchedulerTimer = cortexm4::systick::SysTick;
type WatchDog = ();
type ContextSwitchCallback = ();
Expand Down
20 changes: 15 additions & 5 deletions boards/arty_e21/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use kernel::component::Component;
use kernel::hil;
use kernel::platform::{KernelResources, SyscallDriverLookup};
use kernel::process::ProcessArray;
use kernel::scheduler::priority::PrioritySched;
use kernel::{create_capability, debug, static_init};

#[allow(dead_code)]
Expand Down Expand Up @@ -44,6 +43,12 @@ static mut PROCESS_PRINTER: Option<&'static capsules_system::process_printer::Pr

kernel::stack_size! {0x1000}

struct ProcessManagementCapabilityObj {}
unsafe impl capabilities::ProcessManagementCapability for ProcessManagementCapabilityObj {}

type SchedulerObj =
components::sched::priority::PriorityComponentType<ProcessManagementCapabilityObj>;

/// A structure representing this platform that holds references to all
/// capsules for this platform.
struct ArtyE21 {
Expand All @@ -60,7 +65,7 @@ struct ArtyE21 {
>,
button: &'static capsules_core::button::Button<'static, arty_e21_chip::gpio::GpioPin<'static>>,
// ipc: kernel::ipc::IPC<NUM_PROCS>,
scheduler: &'static PrioritySched,
scheduler: &'static SchedulerObj,
}

/// Mapping of integer syscalls to objects that implement syscalls.
Expand Down Expand Up @@ -89,7 +94,7 @@ impl KernelResources<arty_e21_chip::chip::ArtyExx<'static, ArtyExxDefaultPeriphe
type SyscallDriverLookup = Self;
type SyscallFilter = ();
type ProcessFault = ();
type Scheduler = PrioritySched;
type Scheduler = SchedulerObj;
type SchedulerTimer = ();
type WatchDog = ();
type ContextSwitchCallback = ();
Expand Down Expand Up @@ -239,8 +244,13 @@ unsafe fn start() -> (

chip.enable_all_interrupts();

let scheduler = components::sched::priority::PriorityComponent::new(board_kernel)
.finalize(components::priority_component_static!());
let scheduler = components::sched::priority::PriorityComponent::new(
board_kernel,
ProcessManagementCapabilityObj {},
)
.finalize(components::priority_component_static!(
ProcessManagementCapabilityObj
));

let artye21 = ArtyE21 {
console,
Expand Down
7 changes: 4 additions & 3 deletions boards/clue_nrf52840/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use kernel::hil::usb::Client;
use kernel::platform::chip::Chip;
use kernel::platform::{KernelResources, SyscallDriverLookup};
use kernel::process::ProcessArray;
use kernel::scheduler::round_robin::RoundRobinSched;
#[allow(unused_imports)]
use kernel::{create_capability, debug, debug_gpio, debug_verbose, static_init};

Expand Down Expand Up @@ -151,6 +150,8 @@ type Ieee802154Driver = components::ieee802154::Ieee802154ComponentType<
nrf52840::aes::AesECB<'static>,
>;

type SchedulerObj = components::sched::round_robin::RoundRobinComponentType;

/// Supported drivers by the platform
pub struct Platform {
ble_radio: &'static capsules_extra::ble_advertising_driver::BLE<
Expand Down Expand Up @@ -195,7 +196,7 @@ pub struct Platform {
adc: &'static capsules_core::adc::AdcVirtualized<'static>,
temperature: &'static TemperatureDriver,
humidity: &'static HumidityDriver,
scheduler: &'static RoundRobinSched<'static>,
scheduler: &'static SchedulerObj,
systick: cortexm4::systick::SysTick,
}

Expand Down Expand Up @@ -231,7 +232,7 @@ impl KernelResources<nrf52::chip::NRF52<'static, Nrf52840DefaultPeripherals<'sta
type SyscallDriverLookup = Self;
type SyscallFilter = ();
type ProcessFault = ();
type Scheduler = RoundRobinSched<'static>;
type Scheduler = SchedulerObj;
type SchedulerTimer = cortexm4::systick::SysTick;
type WatchDog = ();
type ContextSwitchCallback = ();
Expand Down
11 changes: 8 additions & 3 deletions boards/components/src/sched/cooperative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,29 @@

// Author: Hudson Ayers <[email protected]>

use capsules_system::scheduler::cooperative::{CoopProcessNode, CooperativeSched};
use core::mem::MaybeUninit;
use kernel::component::Component;
use kernel::process::ProcessArray;
use kernel::scheduler::cooperative::{CoopProcessNode, CooperativeSched};

#[macro_export]
macro_rules! cooperative_component_static {
($N:expr $(,)?) => {{
let coop_sched =
kernel::static_buf!(kernel::scheduler::cooperative::CooperativeSched<'static>);
kernel::static_buf!(capsules_system::scheduler::cooperative::CooperativeSched<'static>);
let coop_nodes = kernel::static_buf!(
[core::mem::MaybeUninit<kernel::scheduler::cooperative::CoopProcessNode<'static>>; $N]
[core::mem::MaybeUninit<
capsules_system::scheduler::cooperative::CoopProcessNode<'static>,
>; $N]
);

(coop_sched, coop_nodes)
};};
}

pub type CooperativeComponentType =
capsules_system::scheduler::cooperative::CooperativeSched<'static>;

pub struct CooperativeComponent<const NUM_PROCS: usize> {
processes: &'static ProcessArray<NUM_PROCS>,
}
Expand Down
10 changes: 7 additions & 3 deletions boards/components/src/sched/mlfq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
use core::mem::MaybeUninit;

use capsules_core::virtualizers::virtual_alarm::{MuxAlarm, VirtualMuxAlarm};
use capsules_system::scheduler::mlfq::{MLFQProcessNode, MLFQSched};
use kernel::component::Component;
use kernel::hil::time;
use kernel::process::ProcessArray;
use kernel::scheduler::mlfq::{MLFQProcessNode, MLFQSched};

#[macro_export]
macro_rules! mlfq_component_static {
Expand All @@ -24,19 +24,23 @@ macro_rules! mlfq_component_static {
capsules_core::virtualizers::virtual_alarm::VirtualMuxAlarm<'static, $A>
);
let mlfq_sched = kernel::static_buf!(
kernel::scheduler::mlfq::MLFQSched<
capsules_system::scheduler::mlfq::MLFQSched<
'static,
capsules_core::virtualizers::virtual_alarm::VirtualMuxAlarm<'static, $A>,
>
);
let mlfq_node = kernel::static_buf!(
[core::mem::MaybeUninit<kernel::scheduler::mlfq::MLFQProcessNode<'static>>; $N]
[core::mem::MaybeUninit<capsules_system::scheduler::mlfq::MLFQProcessNode<'static>>;
$N]
);

(alarm, mlfq_sched, mlfq_node)
};};
}

pub type MLFQComponentType<A> =
capsules_system::scheduler::mlfq::MLFQSched<'static, VirtualMuxAlarm<'static, A>>;

pub struct MLFQComponent<A: 'static + time::Alarm<'static>, const NUM_PROCS: usize> {
alarm_mux: &'static MuxAlarm<'static, A>,
processes: &'static ProcessArray<NUM_PROCS>,
Expand Down
26 changes: 15 additions & 11 deletions boards/components/src/sched/priority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,36 @@
//! .finalize(components::priority_component_static!());
//! ```

use capsules_system::scheduler::priority::PrioritySched;
use core::mem::MaybeUninit;
use kernel::capabilities::ProcessManagementCapability;
use kernel::component::Component;
use kernel::scheduler::priority::PrioritySched;

#[macro_export]
macro_rules! priority_component_static {
() => {{
kernel::static_buf!(kernel::scheduler::priority::PrioritySched)
($CAP:ty $(,)?) => {{
kernel::static_buf!(capsules_system::scheduler::priority::PrioritySched<$CAP>)
};};
}

pub struct PriorityComponent {
pub type PriorityComponentType<CAP> = capsules_system::scheduler::priority::PrioritySched<CAP>;

pub struct PriorityComponent<CAP: ProcessManagementCapability> {
board_kernel: &'static kernel::Kernel,
cap: CAP,
}

impl PriorityComponent {
pub fn new(board_kernel: &'static kernel::Kernel) -> PriorityComponent {
PriorityComponent { board_kernel }
impl<CAP: ProcessManagementCapability> PriorityComponent<CAP> {
pub fn new(board_kernel: &'static kernel::Kernel, cap: CAP) -> Self {
Self { board_kernel, cap }
}
}

impl Component for PriorityComponent {
type StaticInput = &'static mut MaybeUninit<PrioritySched>;
type Output = &'static mut PrioritySched;
impl<CAP: ProcessManagementCapability + 'static> Component for PriorityComponent<CAP> {
type StaticInput = &'static mut MaybeUninit<PrioritySched<CAP>>;
type Output = &'static mut PrioritySched<CAP>;

fn finalize(self, static_buffer: Self::StaticInput) -> Self::Output {
static_buffer.write(PrioritySched::new(self.board_kernel))
static_buffer.write(PrioritySched::new(self.board_kernel, self.cap))
}
}
12 changes: 8 additions & 4 deletions boards/components/src/sched/round_robin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,29 @@
// Author: Hudson Ayers <[email protected]>
// Last modified: 03/31/2020

use capsules_system::scheduler::round_robin::{RoundRobinProcessNode, RoundRobinSched};
use core::mem::MaybeUninit;
use kernel::component::Component;
use kernel::process::ProcessArray;
use kernel::scheduler::round_robin::{RoundRobinProcessNode, RoundRobinSched};

#[macro_export]
macro_rules! round_robin_component_static {
($N:expr $(,)?) => {{
let rr_sched =
kernel::static_buf!(kernel::scheduler::round_robin::RoundRobinSched<'static>);
kernel::static_buf!(capsules_system::scheduler::round_robin::RoundRobinSched<'static>);
let rr_nodes = kernel::static_buf!(
[core::mem::MaybeUninit<kernel::scheduler::round_robin::RoundRobinProcessNode<'static>>;
$N]
[core::mem::MaybeUninit<
capsules_system::scheduler::round_robin::RoundRobinProcessNode<'static>,
>; $N]
);

(rr_sched, rr_nodes)
};};
}

pub type RoundRobinComponentType =
capsules_system::scheduler::round_robin::RoundRobinSched<'static>;

pub struct RoundRobinComponent<const NUM_PROCS: usize> {
processes: &'static ProcessArray<NUM_PROCS>,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use kernel::component::Component;
use kernel::hil::time::Counter;
use kernel::platform::{KernelResources, SyscallDriverLookup};
use kernel::process::ProcessArray;
use kernel::scheduler::round_robin::RoundRobinSched;

#[allow(unused_imports)]
use kernel::{create_capability, debug, debug_gpio, debug_verbose, static_init};
Expand Down Expand Up @@ -93,6 +92,8 @@ type DynamicBinaryStorage<'a> = kernel::dynamic_binary_storage::SequentialDynami
kernel::process::ProcessStandardDebugFull,
NonVolatilePages,
>;
type SchedulerObj = components::sched::round_robin::RoundRobinComponentType;

/// Supported drivers by the platform
pub struct MicroBit {
ble_radio: &'static capsules_extra::ble_advertising_driver::BLE<
Expand Down Expand Up @@ -155,7 +156,7 @@ pub struct MicroBit {
DynamicBinaryStorage<'static>,
>,

scheduler: &'static RoundRobinSched<'static>,
scheduler: &'static SchedulerObj,
systick: cortexm4::systick::SysTick,
}

Expand Down Expand Up @@ -195,7 +196,7 @@ impl KernelResources<nrf52833::chip::NRF52<'static, Nrf52833DefaultPeripherals<'
type SyscallDriverLookup = Self;
type SyscallFilter = ();
type ProcessFault = ();
type Scheduler = RoundRobinSched<'static>;
type Scheduler = SchedulerObj;
type SchedulerTimer = cortexm4::systick::SysTick;
type WatchDog = ();
type ContextSwitchCallback = ();
Expand Down
Loading
Loading