From 708ce0336bb934f36c221cdd3bfdf25fc677c83c Mon Sep 17 00:00:00 2001 From: Mathieu Choplain Date: Wed, 23 Jul 2025 16:17:55 +0200 Subject: [PATCH] kernel: spinlock: update k_spin_lock() documentation wrt context switch Threads must not attempt to context switch if they are holding a spinlock. Add this information to the documentation for k_spin_lock(). Signed-off-by: Mathieu Choplain --- include/zephyr/spinlock.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/zephyr/spinlock.h b/include/zephyr/spinlock.h index 451e91cbd54..e6f444ff05f 100644 --- a/include/zephyr/spinlock.h +++ b/include/zephyr/spinlock.h @@ -175,6 +175,9 @@ static ALWAYS_INLINE void z_spinlock_validate_post(struct k_spinlock *l) * in uniprocessor contexts such that the locking reduces to an * interrupt mask operation. * + * @warning + * Holding a spinlock when a context switch occurs is illegal. + * * @param l A pointer to the spinlock to lock * @return A key value that must be passed to k_spin_unlock() when the * lock is released.