From 06d14080161ab77d20a3f1557051ca3083288586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalle=20Kiet=C3=A4v=C3=A4inen?= Date: Fri, 24 Jan 2025 14:11:20 +0200 Subject: [PATCH] tests: kernel: metairq: Ensure meta-IRQ can preempt a cooperative thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit 52b8e3d3706f7503d6e4e36413c2f78a2ac95480) --- tests/kernel/sched/metairq/src/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/kernel/sched/metairq/src/main.c b/tests/kernel/sched/metairq/src/main.c index be8985413f2..5afd3e07794 100644 --- a/tests/kernel/sched/metairq/src/main.c +++ b/tests/kernel/sched/metairq/src/main.c @@ -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) 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) cnt2 = coop_cnt2; zassert_equal(cnt2, LOOP_CNT, "Unexpected cnt2 at end: %d", cnt2); + printk("thread2 end\n"); + k_sem_give(&coop_sem2); }