executor: fix unsoundness in InterruptExecutor::start.

The initial closure is not actually called in the interrupt, so this is
illegally sending non-Send futures to the interrupt.

Remove the closure, and return a SendSpawner instead.
This commit is contained in:
Dario Nieuwenhuis
2022-04-25 22:09:04 +02:00
parent 52ed08cf95
commit b27feb0619
4 changed files with 22 additions and 28 deletions

View File

@ -124,17 +124,15 @@ fn main() -> ! {
let irq = interrupt::take!(SWI1_EGU1);
irq.set_priority(interrupt::Priority::P6);
let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq));
executor.start(|spawner| {
unwrap!(spawner.spawn(run_high()));
});
let spawner = executor.start();
unwrap!(spawner.spawn(run_high()));
// Medium-priority executor: SWI0_EGU0, priority level 7
let irq = interrupt::take!(SWI0_EGU0);
irq.set_priority(interrupt::Priority::P7);
let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq));
executor.start(|spawner| {
unwrap!(spawner.spawn(run_med()));
});
let spawner = executor.start();
unwrap!(spawner.spawn(run_med()));
// Low priority executor: runs in thread mode, using WFE/SEV
let executor = EXECUTOR_LOW.put(Executor::new());