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

Function lwp_ref_dec

components/lwp/lwp_pid.c:980–1011  ·  view source on GitHub ↗

* @brief Decrements the reference count of a lightweight process (LWP) * * @param[in,out] lwp The lightweight process whose reference count to decrement * * @return int The reference count before decrementing * * @note This function atomically decrements the LWP's reference count. * When the count reaches 1 (meaning this was the last reference): * - For debug builds, sends a me

Source from the content-addressed store, hash-verified

978 * - Calls lwp_free() to release all LWP resources
979 */
980int lwp_ref_dec(struct rt_lwp *lwp)
981{
982 int ref;
983
984 ref = rt_atomic_add(&lwp->ref, -1);
985 LOG_D("%s(lwp=%p,lwp->cmd=%s): before ref=%d", __func__, lwp, lwp->cmd, ref);
986
987 if (ref == 1)
988 {
989 struct rt_channel_msg msg;
990
991 if (lwp->debug)
992 {
993 memset(&msg, 0, sizeof msg);
994 rt_raw_channel_send(gdb_server_channel(), &msg);
995 }
996
997#ifndef ARCH_MM_MMU
998#ifdef RT_LWP_USING_SHM
999 lwp_shm_lwp_free(lwp);
1000#endif /* RT_LWP_USING_SHM */
1001#endif /* not defined ARCH_MM_MMU */
1002 lwp_free(lwp);
1003 }
1004 else
1005 {
1006 /* reference must be a positive integer */
1007 RT_ASSERT(ref > 1);
1008 }
1009
1010 return ref;
1011}
1012
1013/**
1014 * @brief Retrieves a lightweight process (LWP) by its PID while holding the lock

Callers 15

lwp_pid_putFunction · 0.85
_resr_cleanupFunction · 0.85
lwp_cleanupFunction · 0.85
lwp_children_unregisterFunction · 0.85
lwp_execveFunction · 0.85
sys_killFunction · 0.85
sys_thread_createFunction · 0.85
_sys_cloneFunction · 0.85
_sys_forkFunction · 0.85
sys_execveFunction · 0.85

Calls 3

rt_raw_channel_sendFunction · 0.85
gdb_server_channelFunction · 0.85
lwp_freeFunction · 0.85

Tested by 4

test_bst_adptFunction · 0.68
test_user_map_vareaFunction · 0.68
test_user_map_varea_extFunction · 0.68
test_user_accessibleFunction · 0.68