rpi-pico: Multicore-safe atomics using hardware spinlocks.#61
rpi-pico: Multicore-safe atomics using hardware spinlocks.#61damaki wants to merge 3 commits intoAdaCore:masterfrom
Conversation
The default System.BB.Armv6m_Atomic package is not safe for use with the rpi-pico-smp runtimes since it does not ensure atomic accesses between cores. This implements an alternative implementation which uses SPINLOCK31 to ensure mutual exclusion for atomic operations between both cores. 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.
|
Hi @damaki Thanks for the contribution. I am ok with using spin-locks for the atomics, but I don't think the RP2040 run-time should implement all GCC atomic intrinsics. This would be better in an Alire crate and just keep the required functions in the run-time like we do for the other targets. |
|
OK, I've removed the GCC __atomic intrinsics in commit ceed75b. I will create a separate Alire crate for the I originally put them in the runtime to ensure atomicity between |
This change implements an alternative implementation of the
System.BB.Armv6m_Atomicpackage 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 packagepackage 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
masterbranch of this repository.