Skip to content

Commit

Permalink
tests: kernel/sys_mutex: sleep a bit for private_mutex to lock
Browse files Browse the repository at this point in the history
With SMP, the private_mutex may not be locked fast enough by
thread_12 after the thread creation as it might take longer
for a thread to start running the entry function, resulting
in test failure when the main test thread goes into locking
it again. So give it a bit more delay after thread creation
so thread_12 has a chance to lock the private_mutex.

Signed-off-by: Daniel Leung <[email protected]>
  • Loading branch information
dcpleung authored and nashif committed Jul 21, 2023
1 parent c719b70 commit fd3a8ee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/kernel/mutex/sys_mutex/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ ZTEST_USER_OR_NOT(mutex_complex, test_mutex)
k_thread_create(&thread_12_thread_data, thread_12_stack_area, STACKSIZE,
(k_thread_entry_t)thread_12, NULL, NULL, NULL,
K_PRIO_PREEMPT(12), PARTICIPANT_THREAD_OPTIONS, K_NO_WAIT);
k_sleep(K_MSEC(1)); /* Give thread_12 a chance to block on the mutex */
k_sleep(K_MSEC(5)); /* Give thread_12 a chance to block on the mutex */

sys_mutex_unlock(&private_mutex);
sys_mutex_unlock(&private_mutex); /* thread_12 should now have lock */
Expand Down

0 comments on commit fd3a8ee

Please sign in to comment.