Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

samples: smp: pi: keep main thread sleeping until ready #84163

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

williamtcdns
Copy link
Contributor

Use k_sleep(K_FOREVER) in the main thread to keep it sleeping while worker threads are running. The last worker thread to finish calculation wakes up the main thread.

Use `k_sleep(K_FOREVER)` in the main thread to keep it sleeping
while worker threads are running. The last worker thread to finish
calculation wakes up the main thread.

Signed-off-by: William Tambe <[email protected]>
@@ -74,7 +76,9 @@ void test_thread(void *arg1, void *arg2, void *arg3)
buffer += 4;
}

atomic_dec(counter);
if (atomic_dec(counter) == 1) {
k_wakeup(main_tid);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on k_wakeup usage in-tree, I am not certain this is the recommended approach to wake up current thread (vs. e.g. waiting on a semaphore). Maybe @andyross or @peter-mitsis can chime in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants