mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-16 21:05:35 +01:00
don't let the ceiling token escape the critical section
This commit is contained in:
parent
70f573a6c4
commit
aee1d785a9
2 changed files with 19 additions and 4 deletions
15
tests/cfail/ceiling.rs
Normal file
15
tests/cfail/ceiling.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
extern crate cortex_m_srp;
|
||||
|
||||
use cortex_m_srp::{C3, P2, Resource};
|
||||
|
||||
static R1: Resource<(), C3> = Resource::new(());
|
||||
|
||||
fn j1(prio: P2) {
|
||||
let c3 = R1.lock(&prio, |r1, c3| {
|
||||
// forbidden: ceiling token can't outlive critical section
|
||||
c3 //~ error
|
||||
});
|
||||
|
||||
// Would be bad: lockless access to a resource with ceiling = 3
|
||||
let r2 = R1.borrow(&prio, c3);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue