tests/kernel/sched/schedule_api: Relax preemption order constraints
This test was testing for an undocumented and somewhat hyperspecific behavior: when a process reaches a reschedule point and yields to a higher priority thread, and there is another equal priority thread active, which thread gets to run when the higher priority thread finishes its work? The original scheduler (because it leaves the older thread in place in the list) implements the preemption like an interrupt and returns to the original thread, despite the fact that this then resets is time slice quantum unfairly. In SMP mode, where the current threads cannot live in the active list, the thread gets added back to the end of the queue and the other thread runs. In effect, in UP mode "yield" and "reschedule" mean very slightly different things where in SMP they act the same. We don't document either behavior, as it happens. Relax the test constraints by adding a single deliberate k_yield() to unify behavior. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
6a153efc1b
commit
49398cfbf6
1 changed files with 13 additions and 7 deletions
|
@ -356,11 +356,15 @@ void test_unlock_preemptible(void)
|
|||
k_busy_wait(100000);
|
||||
|
||||
k_sched_unlock();
|
||||
/* checkpoint: higher threads get executed */
|
||||
|
||||
/* ensure threads of equal priority can run */
|
||||
k_yield();
|
||||
|
||||
/* checkpoint: higher and equal threads get executed */
|
||||
zassert_true(tdata[0].executed == 1, NULL);
|
||||
for (int i = 1; i < THREADS_NUM; i++) {
|
||||
zassert_true(tdata[i].executed == 0, NULL);
|
||||
}
|
||||
zassert_true(tdata[1].executed == 1, NULL);
|
||||
zassert_true(tdata[2].executed == 0, NULL);
|
||||
|
||||
/* restore environment */
|
||||
teardown_threads();
|
||||
}
|
||||
|
@ -404,11 +408,13 @@ void test_unlock_nested_sched_lock(void)
|
|||
/* unlock another; this let the higher thread to run */
|
||||
k_sched_unlock();
|
||||
|
||||
/* Ensure threads of equal priority run */
|
||||
k_yield();
|
||||
|
||||
/* checkpoint: higher threads NOT get executed */
|
||||
zassert_true(tdata[0].executed == 1, NULL);
|
||||
for (int i = 1; i < THREADS_NUM; i++) {
|
||||
zassert_true(tdata[i].executed == 0, NULL);
|
||||
}
|
||||
zassert_true(tdata[1].executed == 1, NULL);
|
||||
zassert_true(tdata[2].executed == 0, NULL);
|
||||
|
||||
/* restore environment */
|
||||
teardown_threads();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue