Skip to content

Commit

Permalink
Merge pull request #3242 from embassy-rs/cyw43-pls-yield
Browse files Browse the repository at this point in the history
cyw43: make sure to yield if doing busy-polling for interrupts.
  • Loading branch information
Dirbaio authored Aug 8, 2024
2 parents 3afc5e4 + ad4df1c commit b55726c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cyw43/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,13 @@ where
}
Either4::Fourth(()) => {
self.handle_irq(&mut buf).await;

// If we do busy-polling, make sure to yield.
// `handle_irq` will only do a 32bit read if there's no work to do, which is really fast.
// Depending on optimization level, it is possible that the 32-bit read finishes on
// first poll, so it never yields and we starve all other tasks.
#[cfg(feature = "bluetooth")]
embassy_futures::yield_now().await;
}
}
} else {
Expand Down
3 changes: 3 additions & 0 deletions examples/rp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ trouble-host = { version = "0.1.0", features = ["defmt", "gatt"] }

[profile.release]
debug = 2
lto = true
opt-level = 'z'

[profile.dev]
debug = 2
lto = true
opt-level = "z"

Expand Down

0 comments on commit b55726c

Please sign in to comment.