-
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
Move to atomic_polyfill from radium #2
base: main
Are you sure you want to change the base?
Conversation
(It looks like there are some spurious formatting changes due to format on save and not picking up the rustfmt file that matches the old style. I'll fix them) |
(should be fixed now) |
I'm not very familiar with what the embedded-systems part of the ecosystem is up to, which is unfortunate because I'm very interested in that kind of work. So I'd never heard of this, and I really appreciate you bringing it to my attention! Here are my current hold-ups: I'll keep reading this crate and see if I can bridge it myself, but I wanted to write down my immediate thoughts so that both you and I know what I'm thinking and can refer to it in the future.
I think the most useful action here is not to replace
If I understand correctly, I think that from a semantic perspective, programs shouldn't particularly care whether an atomic memory access uses ISA instructions or an IRQ blink: all that matters is that the access is not contended by other writes. As such, I feel pretty comfortable making Does that make sense? Also, we are already planning to lift MSRV to Again: thank you for bringing this to my attention. I definitely want to use |
Hey, I totally get it. Thinking through it out loud, I don't think it would not be crazy to expect that trying to treat an atomic as a bitvec and set or change some bits in an irq handler, which i expect will break on those platforms if they are trying to use irqs to simulate atomics. Now, at the same time, it's bare metal programming anyway, I think if you are this bare metal (no std, etc), you probably know what's going on in your platform enough to realize this would be an issue. I also guess if Radium has to do it this way, it's not like there is some magic other way, so whether you use radium/bitvec or lower level munging, it won't work any better/worse that way anyway. So yeah, makes sense. |
Radium is a nice library for possible atomics, but it is really not usable
in embedded no_std environments. Version 1.0 also significantly changes the
API, and isn't really what bitvec wants (which is atomics that work everywhere).
It instead has "native atomics" and "best-effort atomics".
The standard way to make atomics work everywhere is now to use atomic_polyfill,
which makes atomics available either using native atomics or through polyfills
that use critical sections, and is a drop in replacement for core's Atomic*;
This works on essentially all supported rust environments, both no_std and not.
Radium 0.7 does not work on no_std esp32, for example.
This patch makes bitvec use atomic_polyfill rather than radium.
It requires bumping the minimum rust version slightly from 1.56 to 1.60.
I have not finished updating the docs, wanted to see what you think first.