aboutsummaryrefslogtreecommitdiff
path: root/book
diff options
context:
space:
mode:
authorJorge Aparicio <jorge.aparicio@ferrous-systems.com>2021-07-22 09:17:39 +0200
committerJorge Aparicio <jorge.aparicio@ferrous-systems.com>2021-07-22 09:17:39 +0200
commit5805a05fac2fc5824009586b3ee2fd36dc27fbbf (patch)
treef0f469dcf5414577e088c0c606a334448e5d0bbe /book
parentf9a7efb235854bcb73390988f43b2fae0868e99a (diff)
book/resources: rm #[task_local] mention; add #[lock_free] example
the #[task_local] attribute was removed
Diffstat (limited to 'book')
-rw-r--r--book/en/src/by-example/resources.md20
1 files changed, 12 insertions, 8 deletions
diff --git a/book/en/src/by-example/resources.md b/book/en/src/by-example/resources.md
index 11ba4ce..855cde9 100644
--- a/book/en/src/by-example/resources.md
+++ b/book/en/src/by-example/resources.md
@@ -97,11 +97,15 @@ $ cargo run --example only-shared-access
## Lock-free resource access of mutable resources
-There exists two other options dealing with resources
-
-* `#[lock_free]`: there might be several tasks with the same priority
- accessing the resource without critical section. Since tasks with the
- same priority never can preempt another task on the same priority
- this is safe.
-* `#[task_local]`: there must be only one task using this resource,
- similar to a `static mut` task local resource, but (optionally) set-up by init.
+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.
+
+``` rust
+{{#include ../../../../examples/lock-free.rs}}
+```
+
+``` console
+$ cargo run --example lock-free
+{{#include ../../../../ci/expected/lock-free.run}}
+```