rpi-pico: Multicore-safe atomics using hardware spinlocks. #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change implements an alternative implementation of the
System.BB.Armv6m_Atomic
package for use in the RP2040 which uses a hardware spinlock to ensure mutual exclusion for atomic operations between both cores. This is necessary since the defaultSystem.BB.Armv6m_Atomic package
package is only safe for single processor configurations.Additional GCC atomic built-in functions are also implemented using the same spinlock to ensure atomicity between all atomic operations. These are intended to be used by applications that make use of atomics, for example via the "atomic" crate in Alire.
A minor fix to the RP2040 alarm handler is also included to prevent the interrupt getting stuck set during startup, which in some cases has lead to infinite alarm interrupts.
Please note that I have been able to build and test these changes only with GNAT FSF 12 based on this branch: https://github.com/Fabien-Chouteau/bb-runtimes/tree/gnat-fsf-12 since I unfortunately do not have the toolchain/sources necessary to build the current
master
branch of this repository.