blob: 118dbcf6f863fbdf4aac24a5bbd9d76b9334cbbd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
extern crate cortex_m_rtfm as rtfm;
use rtfm::{C2, C3, P0, P2, Resource, T2};
static R1: Resource<(), C3> = Resource::new(());
fn j1(prio: P2, thr: T2) {
let t3 = thr.raise(
&R1, |thr| {
// forbidden: ceiling token can't outlive the critical section
thr //~ error
}
);
// Would be bad: lockless access to a resource with ceiling = 3
let r2 = R1.access(&prio, t3);
}
fn j2(prio: P0) {
let c16 = rtfm::atomic(
|c16| {
// forbidden: ceiling token can't outlive the critical section
c16 //~ error
},
);
// Would be bad: lockless access to a resource with ceiling = 16
let r1 = R1.access(&prio, c16);
}
|