Skip to content

Commit f5c343f

Browse files
peter-mitsiskartben
authored andcommitted
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 <peter.mitsis@intel.com>
1 parent 6e3f571 commit f5c343f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kernel/condvar.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ int z_impl_k_condvar_broadcast(struct k_condvar *condvar)
9393

9494
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_condvar, broadcast, condvar, woken);
9595

96-
z_reschedule(&lock, key);
96+
97+
if (woken == 0) {
98+
k_spin_unlock(&lock, key);
99+
} else {
100+
z_reschedule(&lock, key);
101+
}
97102

98103
return woken;
99104
}

0 commit comments

Comments
 (0)