kernel: Add static threads to k_thread_foreach functions

Add iterating over the static threads for k_thread_foreach and
k_thread_foreach_unlocked iterator functions

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2020-03-02 14:26:23 +01:00 committed by Johan Hedberg
commit bd3b4b0caf

View file

@ -55,9 +55,15 @@ void k_thread_foreach(k_thread_user_cb_t user_cb, void *user_data)
* k_thread_abort from user_cb.
*/
key = k_spin_lock(&z_thread_monitor_lock);
_FOREACH_STATIC_THREAD(thread_data) {
user_cb(thread_data->init_thread, user_data);
}
for (thread = _kernel.threads; thread; thread = thread->next_thread) {
user_cb(thread, user_data);
}
k_spin_unlock(&z_thread_monitor_lock, key);
#endif
}
@ -71,11 +77,19 @@ void k_thread_foreach_unlocked(k_thread_user_cb_t user_cb, void *user_data)
__ASSERT(user_cb != NULL, "user_cb can not be NULL");
key = k_spin_lock(&z_thread_monitor_lock);
_FOREACH_STATIC_THREAD(thread_data) {
k_spin_unlock(&z_thread_monitor_lock, key);
user_cb(thread_data->init_thread, user_data);
key = k_spin_lock(&z_thread_monitor_lock);
}
for (thread = _kernel.threads; thread; thread = thread->next_thread) {
k_spin_unlock(&z_thread_monitor_lock, key);
user_cb(thread, user_data);
key = k_spin_lock(&z_thread_monitor_lock);
}
k_spin_unlock(&z_thread_monitor_lock, key);
#endif
}