aboutsummaryrefslogtreecommitdiff
path: root/tests/cfail/raise.rs
diff options
context:
space:
mode:
authorJorge Aparicio <jorge@japaric.io>2017-05-08 12:05:42 -0500
committerJorge Aparicio <jorge@japaric.io>2017-05-08 12:05:42 -0500
commitfc4cb7d472dad1ea0fa137bb116bd907efc19601 (patch)
treedd3e462f3fa683ed26c2f6dcd4a2d8be504231c7 /tests/cfail/raise.rs
parent2063697c626a7547f5d9fb140fbc7eb9773a5120 (diff)
replace the ceiling token with a preemption threshold token
Diffstat (limited to 'tests/cfail/raise.rs')
-rw-r--r--tests/cfail/raise.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/cfail/raise.rs b/tests/cfail/raise.rs
new file mode 100644
index 0000000..3d7e564
--- /dev/null
+++ b/tests/cfail/raise.rs
@@ -0,0 +1,24 @@
+extern crate cortex_m_rtfm as rtfm;
+
+use rtfm::{C2, CMax, P1, P3, Resource, T1, T3};
+
+static R1: Resource<i32, C2> = Resource::new(0);
+
+// You CAN'T use `raise` to lower the preemption level
+fn j1(prio: P3, thr: T3) {
+ thr.raise(&R1, |thr| {});
+ //~^ error
+}
+
+static R2: Resource<i32, CMax> = Resource::new(0);
+
+// You CAN'T `raise` the preemption level to the maximum
+fn j2(prio: P1, thr: T1) {
+ thr.raise(&R2, |thr| {});
+ //~^ error
+
+ // Instead use `rtfm::atomic` to access a resource with ceiling C16
+ rtfm::atomic(|thr| {
+ let r2 = R2.access(&prio, thr);
+ });
+}