pico-sdk icon indicating copy to clipboard operation
pico-sdk copied to clipboard

pico_atomic: atomic operations are not multicore-atomic

Open geurtv opened this issue 1 year ago • 1 comments

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.

geurtv avatar Aug 12 '24 13:08 geurtv