diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2017-04-19 14:12:11 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2017-04-19 14:15:18 -0500 |
| commit | aee1d785a914365e64462ce507e27ca917da9055 (patch) | |
| tree | 02e6f19e5e2d9906120d97d071b5df8afc1920e0 /tests | |
| parent | 70f573a6c4bb62b9cefd1300010b535818f72585 (diff) | |
don't let the ceiling token escape the critical section
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cfail/ceiling.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/cfail/ceiling.rs b/tests/cfail/ceiling.rs new file mode 100644 index 0000000..9ddce53 --- /dev/null +++ b/tests/cfail/ceiling.rs @@ -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); +} |
