mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-28 16:14:20 +08:00
[modify] the recycle logic about resource of pthread.
This commit is contained in:
+16
-9
@@ -194,6 +194,7 @@ static void rt_defunct_execute(void)
|
||||
while (1)
|
||||
{
|
||||
rt_thread_t thread;
|
||||
rt_bool_t object_is_systemobject;
|
||||
void (*cleanup)(struct rt_thread *tid);
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
@@ -212,32 +213,38 @@ static void rt_defunct_execute(void)
|
||||
dlmodule_destroy(module);
|
||||
}
|
||||
#endif
|
||||
/* invoke thread cleanup */
|
||||
cleanup = thread->cleanup;
|
||||
if (cleanup != RT_NULL)
|
||||
{
|
||||
cleanup(thread);
|
||||
}
|
||||
|
||||
#ifdef RT_USING_SIGNALS
|
||||
rt_thread_free_sig(thread);
|
||||
#endif
|
||||
|
||||
/* store the point of "thread->cleanup" avoid to lose */
|
||||
cleanup = thread->cleanup;
|
||||
|
||||
/* if it's a system object, not delete it */
|
||||
if (rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE)
|
||||
object_is_systemobject = rt_object_is_systemobject((rt_object_t)thread);
|
||||
if (object_is_systemobject == RT_TRUE)
|
||||
{
|
||||
/* detach this object */
|
||||
rt_object_detach((rt_object_t)thread);
|
||||
}
|
||||
else
|
||||
|
||||
/* invoke thread cleanup */
|
||||
if (cleanup != RT_NULL)
|
||||
{
|
||||
cleanup(thread);
|
||||
}
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
/* if need free, delete it */
|
||||
if (object_is_systemobject == RT_FALSE)
|
||||
{
|
||||
/* release thread's stack */
|
||||
RT_KERNEL_FREE(thread->stack_addr);
|
||||
/* delete thread object */
|
||||
rt_object_delete((rt_object_t)thread);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user