kernel: Split _Swap() API into irqlock and spinlock variants
We want a _Swap() variant that can atomically release/restore a spinlock state in addition to the legacy irqlock. The function as it was is now named "_Swap_irqlock()", while _Swap() now refers to a spinlock and takes two arguments. The former will be going away once existing users (not that many! Swap() is an internal API, and the long port away from legacy irqlocking is going to be happening mostly in drivers) are ported to spinlocks. Obviously on uniprocessor setups, these produce identical code. But SMP requires that the correct API be used to maintain the global lock. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
53cae5f471
commit
aa6e21c24c
10 changed files with 68 additions and 18 deletions
|
@ -81,4 +81,18 @@ static ALWAYS_INLINE void k_spin_unlock(struct k_spinlock *l,
|
|||
_arch_irq_unlock(key.key);
|
||||
}
|
||||
|
||||
/* Internal function: releases the lock, but leaves local interrupts
|
||||
* disabled
|
||||
*/
|
||||
static ALWAYS_INLINE void k_spin_release(struct k_spinlock *l)
|
||||
{
|
||||
#ifdef SPIN_VALIDATE
|
||||
__ASSERT(z_spin_unlock_valid(l), "Not my spinlock!");
|
||||
#endif
|
||||
#ifdef CONFIG_SMP
|
||||
atomic_clear(&l->locked);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_SPINLOCK_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue