diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2017-04-19 15:03:49 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2017-04-19 15:03:49 -0500 |
| commit | aee3c2b29b9c47d5b359cc8ef56fcd0d9a9ba15d (patch) | |
| tree | 746ddfc1d8904e469a67e87964accdac62584d90 /tests/cfail/ceiling.rs | |
| parent | aee1d785a914365e64462ce507e27ca917da9055 (diff) | |
critical: don't let the ceiling token escape the critical section
Diffstat (limited to 'tests/cfail/ceiling.rs')
| -rw-r--r-- | tests/cfail/ceiling.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/cfail/ceiling.rs b/tests/cfail/ceiling.rs index 9ddce53..8ca8413 100644 --- a/tests/cfail/ceiling.rs +++ b/tests/cfail/ceiling.rs @@ -1,6 +1,6 @@ -extern crate cortex_m_srp; +extern crate cortex_m_srp as rtfm; -use cortex_m_srp::{C3, P2, Resource}; +use rtfm::{C3, P0, P2, Resource}; static R1: Resource<(), C3> = Resource::new(()); @@ -13,3 +13,13 @@ fn j1(prio: P2) { // Would be bad: lockless access to a resource with ceiling = 3 let r2 = R1.borrow(&prio, c3); } + +fn j2(prio: P0) { + let c16 = rtfm::critical(|c16| { + // forbidden: ceiling token can't outlive critical section + c16 //~ error + }); + + // Would be bad: lockless access to a resource with ceiling = 16 + let r1 = R1.borrow(&prio, c16); +} |
