From fd1d93e552df23006b50ba2d0ddae6337f505c3e Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Wed, 8 Apr 2020 12:14:24 -0700 Subject: [PATCH] samples: mec15xxevb_assy6853/pm: abort threads before reuse Threads are being re-used for multiple runs, so it is better to stop the threads before reusing the variables for new threads. Signed-off-by: Daniel Leung --- .../power_management/src/power_mgmt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/samples/boards/mec15xxevb_assy6853/power_management/src/power_mgmt.c b/samples/boards/mec15xxevb_assy6853/power_management/src/power_mgmt.c index 6face4d54d2..4d11198ce59 100644 --- a/samples/boards/mec15xxevb_assy6853/power_management/src/power_mgmt.c +++ b/samples/boards/mec15xxevb_assy6853/power_management/src/power_mgmt.c @@ -134,6 +134,15 @@ static void create_tasks(void) } +static void destroy_tasks(void) +{ + k_thread_abort(&threadA_id); + k_thread_abort(&threadB_id); + + k_thread_join(&threadA_id, K_FOREVER); + k_thread_join(&threadB_id, K_FOREVER); +} + static void suspend_all_tasks(void) { k_thread_suspend(&threadA_id); @@ -191,6 +200,8 @@ int test_pwr_mgmt_multithread(bool use_logging, u8_t cycles) resume_all_tasks(); } + destroy_tasks(); + pm_reset_counters(); return 0;