2017-04-21 07:24:54 +02:00
|
|
|
extern crate cortex_m_rtfm as rtfm;
|
2017-04-19 21:12:11 +02:00
|
|
|
|
2017-05-08 19:05:42 +02:00
|
|
|
use rtfm::{C2, C3, P0, P2, Resource, T2};
|
2017-04-19 21:12:11 +02:00
|
|
|
|
|
|
|
static R1: Resource<(), C3> = Resource::new(());
|
|
|
|
|
2017-05-08 19:05:42 +02:00
|
|
|
fn j1(prio: P2, thr: T2) {
|
|
|
|
let t3 = thr.raise(
|
|
|
|
&R1, |thr| {
|
2017-04-22 04:24:28 +02:00
|
|
|
// forbidden: ceiling token can't outlive the critical section
|
2017-05-08 19:05:42 +02:00
|
|
|
thr //~ error
|
2017-04-22 04:24:28 +02:00
|
|
|
}
|
|
|
|
);
|
2017-04-19 21:12:11 +02:00
|
|
|
|
|
|
|
// Would be bad: lockless access to a resource with ceiling = 3
|
2017-05-08 19:05:42 +02:00
|
|
|
let r2 = R1.access(&prio, t3);
|
2017-04-19 21:12:11 +02:00
|
|
|
}
|
2017-04-19 22:03:49 +02:00
|
|
|
|
|
|
|
fn j2(prio: P0) {
|
2017-04-26 04:55:11 +02:00
|
|
|
let c16 = rtfm::atomic(
|
2017-04-22 04:24:28 +02:00
|
|
|
|c16| {
|
|
|
|
// forbidden: ceiling token can't outlive the critical section
|
|
|
|
c16 //~ error
|
|
|
|
},
|
|
|
|
);
|
2017-04-19 22:03:49 +02:00
|
|
|
|
|
|
|
// Would be bad: lockless access to a resource with ceiling = 16
|
2017-04-22 04:38:39 +02:00
|
|
|
let r1 = R1.access(&prio, c16);
|
2017-04-19 22:03:49 +02:00
|
|
|
}
|