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 <mathieu.choplain@st.com>
This commit is contained in:
Mathieu Choplain 2025-07-23 16:17:55 +02:00 committed by Anas Nashif
parent af689aa7b8
commit 708ce0336b

View File

@ -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.