kernel: Add _unlocked() variant to context switch primitives

These functions, for good design reason, take a locking key to
atomically release along with the context swtich.  But there's still a
common pattern in code to do a switch unconditionally by passing
irq_lock() directly.  On SMP that's a little hurtful as it spams the
global lock.  Provide an _unlocked() variant for
_Swap/_reschedule/_pend_curr for simplicity and efficiency.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2018-07-24 14:39:38 -07:00 committed by Anas Nashif
commit 1bf9bd04b1
7 changed files with 30 additions and 15 deletions

View file

@ -54,6 +54,16 @@ struct k_thread *_find_first_thread_to_unpend(_wait_q_t *wait_q,
void idle(void *a, void *b, void *c);
void z_time_slice(int ticks);
static inline void _pend_curr_unlocked(_wait_q_t *wait_q, s32_t timeout)
{
(void) _pend_curr_irqlock(_arch_irq_lock(), wait_q, timeout);
}
static inline void _reschedule_unlocked(void)
{
(void) _reschedule_irqlock(_arch_irq_lock());
}
/* find which one is the next thread to run */
/* must be called with interrupts locked */
#ifdef CONFIG_SMP