MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / sys_thread_find

Function sys_thread_find

components/lwp/lwp_syscall.c:6325–6354  ·  view source on GitHub ↗

* @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.

Source from the content-addressed store, hash-verified

6323 * @see sys_thread_create(), sys_thread_delete()
6324 */
6325rt_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.

Callers

nothing calls this directly

Calls 5

lwp_user_strlenFunction · 0.85
kmem_getFunction · 0.85
lwp_get_from_userFunction · 0.85
kmem_putFunction · 0.85
rt_thread_findFunction · 0.85

Tested by

no test coverage detected