aboutsummaryrefslogtreecommitdiff
path: root/examples/async-task-multiple-prios.rs
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2022-08-05 11:28:02 +0200
committerGravatar Emil Fresk <emil.fresk@gmail.com> 2022-08-05 11:37:16 +0200
commit46a3f2befd6fd821e5747ce9db112c550bc989f3 (patch)
tree384667a40772d821e9d3e95a73293254170adbb5 /examples/async-task-multiple-prios.rs
parentb48a95e87930fa51ef6fb47ad08a95d3159d9bac (diff)
downloadrtic-46a3f2befd6fd821e5747ce9db112c550bc989f3.tar.gz
rtic-46a3f2befd6fd821e5747ce9db112c550bc989f3.tar.zst
rtic-46a3f2befd6fd821e5747ce9db112c550bc989f3.zip
Fix UB in the access of `Priority` for asyc executors
The `Priority` was generated on the stack in the dispatcher which caused it to be dropped after usage. This is now fixed by having the `Priority` being a static variable for executors
Diffstat (limited to 'examples/async-task-multiple-prios.rs')
-rw-r--r--examples/async-task-multiple-prios.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/examples/async-task-multiple-prios.rs b/examples/async-task-multiple-prios.rs
index a90c11bd..d47e87b1 100644
--- a/examples/async-task-multiple-prios.rs
+++ b/examples/async-task-multiple-prios.rs
@@ -16,7 +16,10 @@ mod app {
use systick_monotonic::*;
#[shared]
- struct Shared {}
+ struct Shared {
+ a: u32,
+ b: u32,
+ }
#[local]
struct Local {}
@@ -34,7 +37,7 @@ mod app {
async_task2::spawn().ok();
(
- Shared {},
+ Shared { a: 0, b: 0 },
Local {},
init::Monotonics(Systick::new(cx.core.SYST, 12_000_000)),
)
@@ -49,24 +52,24 @@ mod app {
}
}
- #[task(priority = 1)]
+ #[task(priority = 1, shared = [a, b])]
fn normal_task(_cx: normal_task::Context) {
hprintln!("hello from normal 1").ok();
}
- #[task(priority = 1)]
+ #[task(priority = 1, shared = [a, b])]
async fn async_task(_cx: async_task::Context) {
hprintln!("hello from async 1").ok();
debug::exit(debug::EXIT_SUCCESS);
}
- #[task(priority = 2)]
+ #[task(priority = 2, shared = [a, b])]
fn normal_task2(_cx: normal_task2::Context) {
hprintln!("hello from normal 2").ok();
}
- #[task(priority = 2)]
+ #[task(priority = 2, shared = [a, b])]
async fn async_task2(_cx: async_task2::Context) {
hprintln!("hello from async 2").ok();
}