From 4e79698a997465b1043fa8cbc4a72cdac889341f Mon Sep 17 00:00:00 2001 From: Peter Harper Date: Wed, 5 Nov 2025 10:19:27 +0000 Subject: [PATCH] rp2/pendsv: Fix PendSV_Handler dispatch check when threading enabled. If MICROPY_PY_THREAD is set, PendSV_Handler acquires a mutex and calls the dispatch functions. If pendsv_schedule_dispatch is called by a higher priority interrupt while the mutex is acquired by PendSV_Handler it's possible for the dispatch to not be triggered. Add a check for dispatch calls at the end of PendSV_Handler once the mutex has been released. Fixes issue #18365. Signed-off-by: Peter Harper --- ports/rp2/pendsv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/rp2/pendsv.c b/ports/rp2/pendsv.c index 05b521fde2..a3a855b8d2 100644 --- a/ports/rp2/pendsv.c +++ b/ports/rp2/pendsv.c @@ -180,5 +180,7 @@ void PendSV_Handler(void) { #if MICROPY_PY_THREAD mp_thread_recursive_mutex_unlock(&pendsv_mutex); + // Check if a dispatch occurred while the interrupt was being serviced + pendsv_resume_run_dispatch(); #endif }