From 29b81a23d6fa47d33345164d9ca8c4f1367d7741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Thu, 12 Nov 2020 18:15:42 +0000 Subject: [PATCH 1/2] Add section about task_local and lock_free --- book/en/src/by-example/resources.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/book/en/src/by-example/resources.md b/book/en/src/by-example/resources.md index 9d90fbe366..c34efc9ac0 100644 --- a/book/en/src/by-example/resources.md +++ b/book/en/src/by-example/resources.md @@ -136,3 +136,15 @@ any kind of lock. $ cargo run --example only-shared-access {{#include ../../../../ci/expected/only-shared-access.run}} ``` + +## 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 task local resource, but (optionally) set-up by init. + From b0f6d60c3d9a6b6052d56caddb54d73017668206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Thu, 12 Nov 2020 18:24:57 +0000 Subject: [PATCH 2/2] Add static mut --- book/en/src/by-example/resources.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/en/src/by-example/resources.md b/book/en/src/by-example/resources.md index c34efc9ac0..14a02dee6a 100644 --- a/book/en/src/by-example/resources.md +++ b/book/en/src/by-example/resources.md @@ -146,5 +146,5 @@ There exists two other options dealing with resources 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 task local resource, but (optionally) set-up by init. + similar to a `static mut` task local resource, but (optionally) set-up by init.