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

Function lwp_tid_dec_ref

components/lwp/lwp_tid.c:220–237  ·  view source on GitHub ↗

* @brief Decrement the reference count of a thread and potentially resume its suspender * * @param[in] thread The thread object whose reference count needs to be decremented * * @note This function safely decreases the reference count of a thread object. If the reference * count reaches zero and there is a suspender thread waiting (susp_recycler), it will * be resumed. */

Source from the content-addressed store, hash-verified

218 * be resumed.
219 */
220void lwp_tid_dec_ref(rt_thread_t thread)
221{
222 rt_thread_t susp_putter;
223 if (thread)
224 {
225 RT_ASSERT(rt_object_get_type(&thread->parent) == RT_Object_Class_Thread);
226 susp_putter = thread->susp_recycler;
227 lwp_mutex_take_safe(&tid_lock, RT_WAITING_FOREVER, 0);
228
229 RT_ASSERT(thread->tid_ref_count > 0);
230 thread->tid_ref_count -= 1;
231 if (!thread->tid_ref_count && susp_putter)
232 {
233 rt_thread_resume(susp_putter);
234 }
235 lwp_mutex_release_safe(&tid_lock);
236 }
237}
238
239/**
240 * @brief Associate a thread with a given TID in the thread ID management system

Callers 9

_lwp_setaffinityFunction · 0.85
_futex_lock_piFunction · 0.85
sys_tkillFunction · 0.85
sys_sched_setparamFunction · 0.85
sys_sched_getparamFunction · 0.85
sys_sched_setschedulerFunction · 0.85
sys_sched_getschedulerFunction · 0.85
sys_get_robust_listFunction · 0.85

Calls 4

rt_object_get_typeFunction · 0.85
lwp_mutex_take_safeFunction · 0.85
rt_thread_resumeFunction · 0.85
lwp_mutex_release_safeFunction · 0.85

Tested by

no test coverage detected