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:
Peter Bigot 2021-03-08 08:30:47 -06:00 committed by Anas Nashif
commit 692bac22f5

View file

@ -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,