1 /* 2 * Copyright (c) 2024 Meta Platforms 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include "kernel_shell.h" 8 9 #include <kernel_internal.h> 10 11 #include <zephyr/drivers/timer/system_timer.h> 12 #include <zephyr/debug/symtab.h> 13 #include <zephyr/kernel.h> 14 15 struct thread_entry { 16 const struct k_thread *const thread; 17 bool valid; 18 }; 19 thread_valid_cb(const struct k_thread * cthread,void * user_data)20static void thread_valid_cb(const struct k_thread *cthread, void *user_data) 21 { 22 struct thread_entry *entry = user_data; 23 24 if (cthread == entry->thread) { 25 entry->valid = true; 26 } 27 } 28 z_thread_is_valid(const struct k_thread * thread)29bool z_thread_is_valid(const struct k_thread *thread) 30 { 31 struct thread_entry entry = { 32 .thread = thread, 33 .valid = false, 34 }; 35 36 k_thread_foreach(thread_valid_cb, &entry); 37 38 return entry.valid; 39 } 40 41 SHELL_SUBCMD_SET_CREATE(sub_kernel_thread, (thread)); 42 KERNEL_CMD_ADD(thread, &sub_kernel_thread, "Kernel threads.", NULL); 43