kernel: sched: Do not force preempt when k_sched_unlock()

The scheduler lock is a nestable lock.  Unlocking a nested,
still-having, lock shouldn't preempt the current thread.

	k_sched_lock();
	k_sched_lock();
	k_sched_unlock();  /* <--- this shouldn't be a scheduling point */
	k_sched_unlock();  /* <--- this is a scheduling point */

This commit changes the preempt_ok argument from 1 to 0.  This let
should_preempt() check whether it should preempt at the point or not.

This fixes #17869.

Signed-off-by: Yasushi SHOJI <y-shoji@ispace-inc.com>
This commit is contained in:
Yasushi SHOJI 2019-07-31 11:19:08 +09:00 committed by Carles Cufí
commit 20d072465d

View file

@ -555,7 +555,7 @@ void k_sched_unlock(void)
LOCKED(&sched_spinlock) {
++_current->base.sched_locked;
update_cache(1);
update_cache(0);
}
K_DEBUG("scheduler unlocked (%p:%d)\n",