* @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. */
| 218 | * be resumed. |
| 219 | */ |
| 220 | void 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 |
no test coverage detected