Commit 06d14080 authored by Kalle Kietäväinen's avatar Kalle Kietäväinen Committed by github-actions[bot]
Browse files

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: default avatarKalle Kietäväinen <kalle.kietavainen@silabs.com>
(cherry picked from commit 52b8e3d3)
parent 1c0fb77c
Loading
Loading
Loading
Loading
+6 −0
Changes for tests/kernel/sched/metairq/src/main.c: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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);
}