diff --git a/examples/lm3s6965/examples/spawn_local.rs b/examples/lm3s6965/examples/spawn_local.rs new file mode 100644 index 00000000000..74bb58237b0 --- /dev/null +++ b/examples/lm3s6965/examples/spawn_local.rs @@ -0,0 +1,39 @@ +#![no_main] +#![no_std] + +use panic_semihosting as _; + +#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] +mod app { + use cortex_m_semihosting::{debug, hprintln}; + use super::*; + + #[shared] + struct Shared {} + + #[local] + struct Local {} + + #[init] + fn init(_cx: init::Context) -> (Shared, Local) { + task1::spawn().unwrap(); + //task2::spawn(Default::default()).ok(); <--- This is rejected since not all args are Send and Sync + (Shared {}, Local {}) + } + + #[task(priority = 1)] + async fn task1(cx: task1::Context) { + hprintln!("Hello from task1!"); + cx.local_spawner.task2(Default::default()).unwrap(); + } + + // Task where some args are !Send/!Sync + #[task(priority = 1)] + async fn task2(_cx: task2::Context, _nsns: NotSendNotSync) { + hprintln!("Hello from task2!"); + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + } +} + +#[derive(Default, Debug)] +struct NotSendNotSync(core::marker::PhantomData<*mut u8>); diff --git a/examples/lm3s6965/examples/wait-queue.rs b/examples/lm3s6965/examples/wait-queue.rs index 7be1c0a89cc..e60d919170f 100644 --- a/examples/lm3s6965/examples/wait-queue.rs +++ b/examples/lm3s6965/examples/wait-queue.rs @@ -28,8 +28,8 @@ mod app { fn init(cx: init::Context) -> (Shared, Local) { Mono::start(cx.core.SYST, 12_000_000); - incrementer::spawn(cx.local.wait_queue).ok().unwrap(); - waiter::spawn(cx.local.wait_queue).ok().unwrap(); + incrementer::spawn(&*cx.local.wait_queue).ok().unwrap(); + waiter::spawn(&*cx.local.wait_queue).ok().unwrap(); let count = 0;