-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] shared access to resources (resources = [&FOO]) #14
Comments
About unresolved question, you can have a usecase: #[rtfm::app(device = ..)]
const APP: () = {
// ..
#[task(priority = 1, resources = [&FOO])]
fn foo() { /* .. */ }
#[task(priority = 2, resources = [FOO])]
fn bar() { /* .. */ }
#[task(priority = 3, resources = [&FOO])]
fn baz() { /* .. */ }
} In this case, a lock in foo must block only until priority 2, priority 3 can still run. |
and, supposing |
Of course, |
... or going back to claim/claim_mut notation.
Notice here, resource access is wait free under RTFM, thus claiming a resource does not have the non deterministic behavior of a traditional mutex lock. Its a very important property for static response time analysis, and other timing related matters.
Best regards
Per
…________________________________
Från: Guillaume P. <[email protected]>
Skickat: den 12 februari 2019 17:24:10
Till: japaric/cortex-m-rtfm
Kopia: Subscribed
Ämne: Re: [japaric/cortex-m-rtfm] [RFC] shared access to resources (resources = [&FOO]) (#129)
Of course, lock and lock_mut would be more rustic, but not backward compatible (and thus only for 0.5).
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<https://github.com/japaric/cortex-m-rtfm/issues/129#issuecomment-462827837>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AD5naEJMVn2g8svU1L_6MW0k5s6FVBSdks5vMuqqgaJpZM4Z7PYf>.
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/japaric/cortex-m-rtfm","title":"japaric/cortex-m-rtfm","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/japaric/cortex-m-rtfm"}},"updates":{"snippets":[{"icon":"PERSON","message":"@TeXitoi in rtfm-rs/cortex-m-rtfm#129: Of course, `lock` and `lock_mut` would be more rustic, but not backward compatible (and thus only for 0.5)."}],"action":{"name":"View Issue","url":"https://github.com/japaric/cortex-m-rtfm/issues/129#issuecomment-462827837"}}} [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/japaric/cortex-m-rtfm/issues/129#issuecomment-462827837", "url": "https://github.com/japaric/cortex-m-rtfm/issues/129#issuecomment-462827837", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]
|
Doing this would make the resource API un-symmetric, as the order of priorities and references to resources would create different behavior. |
Hi folks. I think symmetry is key here. I will make a separate RFC on that matter. |
This RFC is now two years old. Has it been superseded? |
No, just not decided on. |
Echoing some up-to-date notes from the Matrix channel which may be of use: @korken89 writes:
The current implementation (allowing |
Summary
Extend the syntax of the
resources
field to let the user specify when shared,instead of exclusive (today's default), access to a resource is required.
Specifying shared access can reduce the number of required critical sections in
some scenarios.
Background
Consider this example:
With the current rules, the task
bar
needs a critical section to accessFOO
.However, that critical section is not really needed because task
baz
cannotmodify
FOO
.Design
The parser will be modified to accept both
$ident
and&$ident
in lists ofresources. The former syntax, which exists today, indicates exclusive access to
the resource -- its semantics are unchanged; the latter syntax indicates shared
access to the resource.
When shared access is specified the task will receive a shared reference (
&_
)to the resource data rather than a
Mutex
proxy.If shared access is requested from two or more tasks that run at different
priorities then the resource type must implement the
Sync
trait. This isrequired to prevent types with interior mutability (like
Cell
andRefCell
)from being accessed without a critical section, and potentially modified, from
those tasks as that could result in UB.
With the proposed changes our opening example can be updated as follows:
Unresolved questions
It's unclear what to do in this scenario, other than raise a compiler error:
No optimization can be applied here. The task
foo
needs a critical section toaccess the resource data, in any form, but the
lock
API doesn't make sensehere because that grants an exclusive reference (
&mut _
) to the data andshared access was requested.
The text was updated successfully, but these errors were encountered: