From f5c343fc93e865d65a7539d5c160cb0ebb37e91f Mon Sep 17 00:00:00 2001 From: Peter Mitsis Date: Mon, 16 Dec 2024 12:45:59 -0800 Subject: [PATCH] kernel: condvar: broadcast does not always need reschedule When doing a condition variable broadcast, a full reschedule is only needed if at least one thread was awakened. Signed-off-by: Peter Mitsis --- kernel/condvar.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/condvar.c b/kernel/condvar.c index 615a6b30f15..d00eb552ff7 100644 --- a/kernel/condvar.c +++ b/kernel/condvar.c @@ -93,7 +93,12 @@ int z_impl_k_condvar_broadcast(struct k_condvar *condvar) SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_condvar, broadcast, condvar, woken); - z_reschedule(&lock, key); + + if (woken == 0) { + k_spin_unlock(&lock, key); + } else { + z_reschedule(&lock, key); + } return woken; }