* @brief Finds a thread by its name. * * This system call is used to search for a thread based on its name. It returns a reference to the * thread if found, otherwise it returns `RT_NULL`. The name comparison is case-sensitive. * * @param[in] name The name of the thread to search for. This should be a valid string that * uniquely identifies the thread within the system.
| 6323 | * @see sys_thread_create(), sys_thread_delete() |
| 6324 | */ |
| 6325 | rt_thread_t sys_thread_find(char *name) |
| 6326 | { |
| 6327 | int len = 0; |
| 6328 | char *kname = RT_NULL; |
| 6329 | rt_thread_t thread; |
| 6330 | |
| 6331 | len = lwp_user_strlen(name); |
| 6332 | if (len <= 0) |
| 6333 | { |
| 6334 | return RT_NULL; |
| 6335 | } |
| 6336 | |
| 6337 | kname = (char *)kmem_get(len + 1); |
| 6338 | if (!kname) |
| 6339 | { |
| 6340 | return RT_NULL; |
| 6341 | } |
| 6342 | |
| 6343 | if (lwp_get_from_user(kname, (void *)name, len + 1) != (len + 1)) |
| 6344 | { |
| 6345 | kmem_put(kname); |
| 6346 | return RT_NULL; |
| 6347 | } |
| 6348 | |
| 6349 | thread = rt_thread_find(name); |
| 6350 | |
| 6351 | kmem_put(kname); |
| 6352 | |
| 6353 | return thread; |
| 6354 | } |
| 6355 | |
| 6356 | /** |
| 6357 | * @brief Gets the current system tick count. |
nothing calls this directly
no test coverage detected