raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.26k stars 838 forks source link

Runtime for C11 atomics missing #1642

Closed sgstreet closed 2 months ago

sgstreet commented 4 months ago

The Pico-SDK does not provide an implementation of standard C11 atomic functions, this makes implementing multi-core algorithms more complicated and error prone while decreasing software potability from Cotrex-M3/4/7 code bases. Unfortunately the Cortex-M0+ does not provide LDREX and STREX instructions for multi-core lock-less atomic operations and thus most tool chains do not provide implementations.

The Pico-SDK should provide an implementation of the C11 atomic functions using interrupt masking for single core atomic read/write/modify operations combined with hardware spin locks to accommodate the RP2040 symmetric dual core design.

sgstreet commented 4 months ago

PR inbound later today.

sgstreet commented 4 months ago

@kilograham the PR is up and I'm looking forward to your thoughts.