-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
589: Fine grained concurrency on thumbv6m (no BASEPRI). r=korken89 a=perlindgren This is an experimental implementation of SRP based scheduling on the M0/M0+ (thumbv6m) architecture. The aim is a (sub)-zero abstraction to the resource protection (locking mechanism). Please try, but not merge yet, since its an early POC. Co-authored-by: Per Lindgren <[email protected]>
- Loading branch information
Showing
9 changed files
with
434 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
init | ||
idle p0 started | ||
t2 p4 called 1 time | ||
enter lock s4 0 | ||
t3 p4 exit | ||
idle enter lock s3 0 | ||
idle pend t0 | ||
idle pend t1 | ||
idle pend t2 | ||
t2 p4 called 2 times | ||
enter lock s4 1 | ||
t3 p4 exit | ||
idle still in lock s3 0 | ||
t1 p3 called 1 time | ||
t1 enter lock s4 2 | ||
t1 pend t0 | ||
t1 pend t2 | ||
t1 still in lock s4 2 | ||
t2 p4 called 3 times | ||
enter lock s4 2 | ||
t3 p4 exit | ||
t1 p3 exit | ||
t0 p2 called 1 time | ||
t0 p2 exit | ||
|
||
back in idle | ||
enter lock s2 0 | ||
idle pend t0 | ||
idle pend t1 | ||
t1 p3 called 2 times | ||
t1 enter lock s4 3 | ||
t1 pend t0 | ||
t1 pend t2 | ||
t1 still in lock s4 3 | ||
t2 p4 called 4 times | ||
enter lock s4 3 | ||
t3 p4 exit | ||
t1 p3 exit | ||
idle pend t2 | ||
t2 p4 called 5 times | ||
enter lock s4 4 | ||
t3 p4 exit | ||
idle still in lock s2 0 | ||
t0 p2 called 2 times | ||
t0 p2 exit | ||
|
||
idle exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
//! examples/complex.rs | ||
#![deny(unsafe_code)] | ||
#![deny(warnings)] | ||
#![no_main] | ||
#![no_std] | ||
|
||
use panic_semihosting as _; | ||
|
||
#[rtic::app(device = lm3s6965)] | ||
mod app { | ||
|
||
use cortex_m_semihosting::{debug, hprintln}; | ||
use lm3s6965::Interrupt; | ||
|
||
#[shared] | ||
struct Shared { | ||
s2: u32, // shared with ceiling 2 | ||
s3: u32, // shared with ceiling 3 | ||
s4: u32, // shared with ceiling 4 | ||
} | ||
|
||
#[local] | ||
struct Local {} | ||
|
||
#[init] | ||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { | ||
hprintln!("init").unwrap(); | ||
|
||
( | ||
Shared { | ||
s2: 0, | ||
s3: 0, | ||
s4: 0, | ||
}, | ||
Local {}, | ||
init::Monotonics(), | ||
) | ||
} | ||
|
||
#[idle(shared = [s2, s3])] | ||
fn idle(mut cx: idle::Context) -> ! { | ||
hprintln!("idle p0 started").ok(); | ||
rtic::pend(Interrupt::GPIOC); | ||
cx.shared.s3.lock(|s| { | ||
hprintln!("idle enter lock s3 {}", s).ok(); | ||
hprintln!("idle pend t0").ok(); | ||
rtic::pend(Interrupt::GPIOA); // t0 p2, with shared ceiling 3 | ||
hprintln!("idle pend t1").ok(); | ||
rtic::pend(Interrupt::GPIOB); // t1 p3, with shared ceiling 3 | ||
hprintln!("idle pend t2").ok(); | ||
rtic::pend(Interrupt::GPIOC); // t2 p4, no sharing | ||
hprintln!("idle still in lock s3 {}", s).ok(); | ||
}); | ||
hprintln!("\nback in idle").ok(); | ||
|
||
cx.shared.s2.lock(|s| { | ||
hprintln!("enter lock s2 {}", s).ok(); | ||
hprintln!("idle pend t0").ok(); | ||
rtic::pend(Interrupt::GPIOA); // t0 p2, with shared ceiling 2 | ||
hprintln!("idle pend t1").ok(); | ||
rtic::pend(Interrupt::GPIOB); // t1 p3, no sharing | ||
hprintln!("idle pend t2").ok(); | ||
rtic::pend(Interrupt::GPIOC); // t2 p4, no sharing | ||
hprintln!("idle still in lock s2 {}", s).ok(); | ||
}); | ||
hprintln!("\nidle exit").ok(); | ||
|
||
debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator | ||
|
||
loop { | ||
cortex_m::asm::nop(); | ||
} | ||
} | ||
|
||
#[task(binds = GPIOA, priority = 2, local = [times: u32 = 0], shared = [s2, s3])] | ||
fn t0(cx: t0::Context) { | ||
// Safe access to local `static mut` variable | ||
*cx.local.times += 1; | ||
|
||
hprintln!( | ||
"t0 p2 called {} time{}", | ||
*cx.local.times, | ||
if *cx.local.times > 1 { "s" } else { "" } | ||
) | ||
.ok(); | ||
hprintln!("t0 p2 exit").ok(); | ||
} | ||
|
||
#[task(binds = GPIOB, priority = 3, local = [times: u32 = 0], shared = [s3, s4])] | ||
fn t1(mut cx: t1::Context) { | ||
// Safe access to local `static mut` variable | ||
*cx.local.times += 1; | ||
|
||
hprintln!( | ||
"t1 p3 called {} time{}", | ||
*cx.local.times, | ||
if *cx.local.times > 1 { "s" } else { "" } | ||
) | ||
.ok(); | ||
|
||
cx.shared.s4.lock(|s| { | ||
hprintln!("t1 enter lock s4 {}", s).ok(); | ||
hprintln!("t1 pend t0").ok(); | ||
rtic::pend(Interrupt::GPIOA); // t0 p2, with shared ceiling 2 | ||
hprintln!("t1 pend t2").ok(); | ||
rtic::pend(Interrupt::GPIOC); // t2 p4, no sharing | ||
hprintln!("t1 still in lock s4 {}", s).ok(); | ||
}); | ||
|
||
hprintln!("t1 p3 exit").ok(); | ||
} | ||
|
||
#[task(binds = GPIOC, priority = 4, local = [times: u32 = 0], shared = [s4])] | ||
fn t2(mut cx: t2::Context) { | ||
// Safe access to local `static mut` variable | ||
*cx.local.times += 1; | ||
|
||
hprintln!( | ||
"t2 p4 called {} time{}", | ||
*cx.local.times, | ||
if *cx.local.times > 1 { "s" } else { "" } | ||
) | ||
.unwrap(); | ||
|
||
cx.shared.s4.lock(|s| { | ||
hprintln!("enter lock s4 {}", s).ok(); | ||
*s += 1; | ||
}); | ||
hprintln!("t3 p4 exit").ok(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ pub fn impl_mutex( | |
#priority, | ||
CEILING, | ||
#device::NVIC_PRIO_BITS, | ||
&MASKS, | ||
f, | ||
) | ||
} | ||
|
Oops, something went wrong.