aboutsummaryrefslogtreecommitdiff
path: root/book/en
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-07-22 10:51:16 +0000
committerGitHub <noreply@github.com>2021-07-22 10:51:16 +0000
commitadb4bc4c4ea85b12a6d7f75821e76ee33a9a8e70 (patch)
tree6a537ceca031f62280f022db0bd4577f1efd5d9c /book/en
parentb6e8e37c3c543bebaec17a77760396c1e30afcdf (diff)
parent3eac8b91cfd37c27e75da5c7e21e394d10f97adf (diff)
Merge #502
502: book/resources: highlight that `#[lock_free]` includes a compile-time check r=AfoHT a=japaric for the "same priority requirement"; this prevents data races Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
Diffstat (limited to 'book/en')
-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 855cde9..4f6c3c3 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}}