Skip to content

Commit f5f258f

Browse files
Nicolas Pitrejhedberg
authored andcommitted
tests: kernel: smp_abort: add delay to ensure circular dependency
The test_smp_thread_abort_deadlock test assumes all CPUs will simultaneously establish a circular abort dependency (each thread aborts the next in a ring). However, on platforms with large emulator/simulator quantum sizes, one thread's ISR may complete and return before another thread even calls k_thread_abort() on it, preventing the circular dependency from forming. This manifested on ARMv8-R FVP but not on QEMU or ARMv8-A/ARMv9-A FVP due to different timing characteristics and quantum sizes. Add a k_busy_wait(100) after k_thread_abort() to give all CPUs time to call abort before any ISR completes. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
1 parent 8b2c75a commit f5f258f

File tree

1 file changed

+9
-0
lines changed
  • tests/kernel/smp_abort/src

1 file changed

+9
-0
lines changed

tests/kernel/smp_abort/src/main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ static void isr(const void *args)
3939
}
4040

4141
k_thread_abort(var->target); /* Abort thread on another CPU */
42+
43+
/*
44+
* Give other CPUs time to also call k_thread_abort() to establish
45+
* the circular dependency that this test is designed to exercise.
46+
* On platforms with large emulator/simulator quantum sizes, without
47+
* this delay one thread may complete its ISR and return before
48+
* another thread even calls k_thread_abort() on it.
49+
*/
50+
k_busy_wait(100);
4251
}
4352

4453
static void thread_entry(void *p1, void *p2, void *p3)

0 commit comments

Comments
 (0)