Browse Source

tests: kernel: metairq: Ensure meta-IRQ can preempt a cooperative thread

The intention of the test is to have a meta-IRQ preempt a cooperative
thread, then ensure the same cooperative thread is resumed back to instead
of a higher priority thread. Thus, the test needs to assert that the lower
priority cooperative thread is not yet complete when it makes the higher
priority thread ready to run.

This change reveals bugs like #80574, where the meta-IRQ is unable to
preempt a cooperative thread.

Signed-off-by: Kalle Kietäväinen <kalle.kietavainen@silabs.com>
(cherry picked from commit 52b8e3d370)
backport-84509-to-v4.0-branch
Kalle Kietäväinen 6 months ago committed by github-actions[bot]
parent
commit
06d1408016
  1. 6
      tests/kernel/sched/metairq/src/main.c

6
tests/kernel/sched/metairq/src/main.c

@ -77,6 +77,8 @@ void metairq_thread(void *p1, void *p2, void *p3) @@ -77,6 +77,8 @@ void metairq_thread(void *p1, void *p2, void *p3)
k_msleep(WAIT_MS);
zassert_not_equal(coop_cnt2, LOOP_CNT, "thread2 wasn't preempted");
printk("give sem1\n");
k_sem_give(&coop_sem1);
@ -113,6 +115,8 @@ void coop_thread1(void *p1, void *p2, void *p3) @@ -113,6 +115,8 @@ void coop_thread1(void *p1, void *p2, void *p3)
cnt2 = coop_cnt2;
zassert_equal(cnt2, LOOP_CNT, "Unexpected cnt2 at end: %d", cnt2);
printk("thread1 end\n");
k_sem_give(&coop_sem1);
}
@ -155,6 +159,8 @@ void coop_thread2(void *p1, void *p2, void *p3) @@ -155,6 +159,8 @@ void coop_thread2(void *p1, void *p2, void *p3)
cnt2 = coop_cnt2;
zassert_equal(cnt2, LOOP_CNT, "Unexpected cnt2 at end: %d", cnt2);
printk("thread2 end\n");
k_sem_give(&coop_sem2);
}

Loading…
Cancel
Save