pico-sdk
pico-sdk copied to clipboard
pico_atomic: atomic operations are not multicore-atomic
From SDK 2.0.0 release notes:
Additional support for C11 atomic functions using spin lock number PICO_SPINLOCK_ID_ATOMIC.
and
On RP2040, all functions are implemented via spinlock.
Well ... no? PICO_SPINLOCK_ID_ATOMIC doesn't seem to be used anywhere in the pico-sdk sources and spinlocks are nowhere to be found in atomic.c.
The atomic operations in atomic.c call atomic_lock() which itself only calls save_and_disable_interrupts(), and if I'm not mistaken this only disables interrupts on the current cpu core.