mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 19:50:30 +01:00
Previously, this was subject to races incrementing/decrementing the counter variable pendsv_lock. Technically, all that's needed here would be to make pendsv_lock an atomic counter. This implementation fulfils a stronger guarantee: it also provides mutual exclusion for the core which calls pendsv_suspend(). This is because the current use of pendsv_suspend/resume in MicroPython is to ensure exclusive access to softtimer data structures, and this does require mutual exclusion. The conceptually cleaner implementation would split the mutual exclusion part out into a softtimer-specific spinlock, but this increases the complexity and doesn't seem like it makes for a better implementation in the long run. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
3.5 KiB
3.5 KiB