tests: footprint: fix thread start races
The test granted access to the user work queue stack from the user work thread; this was done by k_work_user_queue_start() so was unnecessary. Document why it's ok to grant other access after the work thread was started. Fix a race condition where the non-work user thread might have started before it was given access to the resources it needs. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
72dfb34cdf
commit
692bac22f5
1 changed files with 5 additions and 2 deletions
|
@ -111,13 +111,16 @@ void run_workq(void)
|
||||||
K_THREAD_STACK_SIZEOF(user_workq_stack),
|
K_THREAD_STACK_SIZEOF(user_workq_stack),
|
||||||
CONFIG_MAIN_THREAD_PRIORITY, NULL);
|
CONFIG_MAIN_THREAD_PRIORITY, NULL);
|
||||||
|
|
||||||
|
/* The work queue thread has been started, but it's OK because
|
||||||
|
* it doesn't need these permissions until something's submitted
|
||||||
|
* to it.
|
||||||
|
*/
|
||||||
k_mem_domain_add_thread(&footprint_mem_domain, &user_workq.thread);
|
k_mem_domain_add_thread(&footprint_mem_domain, &user_workq.thread);
|
||||||
k_thread_access_grant(&user_workq.thread, &user_workq_stack);
|
|
||||||
k_thread_access_grant(&user_workq.thread, &sync_sema);
|
k_thread_access_grant(&user_workq.thread, &sync_sema);
|
||||||
|
|
||||||
tid = k_thread_create(&my_thread, my_stack_area, STACK_SIZE,
|
tid = k_thread_create(&my_thread, my_stack_area, STACK_SIZE,
|
||||||
simple_user_workq_thread, NULL, NULL, NULL,
|
simple_user_workq_thread, NULL, NULL, NULL,
|
||||||
0, K_USER, K_NO_WAIT);
|
0, K_USER, K_FOREVER);
|
||||||
|
|
||||||
k_thread_access_grant(tid, &sync_sema,
|
k_thread_access_grant(tid, &sync_sema,
|
||||||
&user_workq.thread, &user_workq.queue,
|
&user_workq.thread, &user_workq.queue,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue