-
Notifications
You must be signed in to change notification settings - Fork 94
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
Are rwlock
and spin_mutex
compatible with portable_atomic
?
#151
Comments
You need to enable cfg or the https://github.com/mvdnes/spin-rs#feature-flags
|
Okay thanks that fixed it! |
For future reference: the reason for this added complexity is that enabling That said, the error message here could definitely be improved. I'll have a look into this. |
Thanks for that additional context, definitely makes sense you'd want to have users explicitly do an unsafe behavior. 👍 |
To be clear: This relates to the single-core cfg of
@zesterer Could you elaborate on this? I'm not aware of such a problem. |
I don't believe Rust currently defines what 'parallelism' and 'thread safety' mean to a sufficient degree to conclusively rule out unsafety on single-core systems, since 'single-core' isn't a thing that has a specific relationship with Rust's compilation model, that I'm aware of. I think, in practice, it's probably never going to result in unexpected behaviour unless you're doing strange things like accessing spinlocks in interrupt handlers and the like, but it's still worth considering that your system superficially not possessing multiple threads of execution doesn't guarantee safety. |
In this commit I made some changes that result in the following error when using
|
On these platforms, if they are single-core and interrupts are disabled, there is no way to break atomicity except reordering memory accesses by the compiler (well, the compiler actually shouldn't be able to reorder memory accesses in such a way as to affect the results, though). And the inline assembly used to disable and restore the interrupt state implies a compiler fence. So, the problem you mention does not exist in
Hmm, I'm concerned that this will prevent the use of the Instead, I think it would be better to add something like |
Filed taiki-e/portable-atomic#100 to implement this approach. |
Would you suggest that we revert the change to |
Yes, I would suggest reverting it and enabling I opened #152 to do these. |
Hello,
I'm trying to build a no_std crate for
--target thumbv6m-none-eabi
and running into some issues with rwlock and spin mutex. The error messages are below.Here's spin in my Cargo.toml:
Here's my full cargo tree:
And here are the error messages:
The text was updated successfully, but these errors were encountered: