-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Support atomic CAS on no-std pre-v6 ARM targets (e.g., thumbv4t-none-eabi) #26
Comments
Speaking as the
|
@Lokathor Thanks for your comment!
Oh, that's really bad... Thanks for the detailed explanation!
This crate's interrupt disabling-based implementation will only1 be enabled if the end-user explicitly enables the unsafe cfg, so I think it's okay if we update the cfg documentation to make it clear that it disables interrupts.
Ah, that is indeed important. I think other targets have similar issues and we need to update the cfg documentation to mention it. (Since it requires explicitly enabling unsafe cfg anyway, I think it's okay as long as it's properly documented.)
Using a weak definition to provide a default implementation that can be overridden is a very interesting idea! Footnotes
|
(For atomic builtins, it is now tracked by #33) |
Pre-v6 ARM targets (except for Linux) don't support atomic CAS.
As far as I know, there are several ways to support this:
Spinlock based onSWP
instruction. (multi-core safety: yes)implementation: Support atomic CAS on no-std pre-v6 ARM using SWP instruction #27EDIT: this is broken on single-core + interrupt situations
Disabling interrupts. (What we are currently doing for thumbv6m and other targets.) (multi-core safety: no)
Is there a standardized way to do this? Maybe interrupt disable bits in CPSR?
implementation: interrupt: Support no-std pre-v6 ARM targets #28
Use atomic builtins. (Let the user implement the actual atomic logic.) (multi-core safety: implementation-dependent)
See this comment for problems I am aware of.
implementation: Add cfg to use
__atomic_*
builtins #30Optional feature to use 3rd party crate like critical-section. (Let the user implement the actual atomic logic.) (multi-core safety: no by default)
However, critical-section 0.2 should be enabled only under the unsafe cfg because the default implementation is unsound on multi-core systems.
Even on critical-section 1.0, it seems that this also needs to be unsafe because it has the same problems as the case using atomic builtins.
The text was updated successfully, but these errors were encountered: