aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge.aparicio@ferrous-systems.com> 2021-07-22 10:35:09 +0200
committerGravatar Jorge Aparicio <jorge.aparicio@ferrous-systems.com> 2021-07-22 10:35:09 +0200
commit3eac8b91cfd37c27e75da5c7e21e394d10f97adf (patch)
tree7ce51ec93f9592bd53f8588e59f1b2b2c3678b19
parentc62fd967d77ccf72c08ea720c21777e367ab4125 (diff)
downloadrtic-3eac8b91cfd37c27e75da5c7e21e394d10f97adf.tar.gz
rtic-3eac8b91cfd37c27e75da5c7e21e394d10f97adf.tar.zst
rtic-3eac8b91cfd37c27e75da5c7e21e394d10f97adf.zip
book/resources: highlight that `#[lock_free]` includes a compile-time check
for the "same priority requirement"; this prevents data races
-rw-r--r--book/en/src/by-example/resources.md1
1 files changed, 1 insertions, 0 deletions
diff --git a/book/en/src/by-example/resources.md b/book/en/src/by-example/resources.md
index 855cde93..4f6c3c31 100644
--- a/book/en/src/by-example/resources.md
+++ b/book/en/src/by-example/resources.md
@@ -100,6 +100,7 @@ $ cargo run --example only-shared-access
A critical section is *not* required to access a `#[shared]` resource that's only accessed by tasks running at the *same* priority.
In this case, you can opt out of the `lock` API by adding the `#[lock_free]` field-level attribute to the resource declaration (see example below).
Note that this is merely a convenience: if you do use the `lock` API, at runtime the framework will *not* produce a critical section.
+Also worth noting: using `#[lock_free]` on resources shared by tasks running at different priorities will result in a *compile-time* error -- not using the `lock` API would be a data race in that case.
``` rust
{{#include ../../../../examples/lock-free.rs}}