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

Function lwp_free

components/lwp/lwp_pid.c:699–781  ·  view source on GitHub ↗

* @brief Free all resources associated with a lightweight process (LWP) * * @param[in,out] lwp Lightweight process to be freed * * @note when reference is 0, a lwp can be released */

Source from the content-addressed store, hash-verified

697 * @note when reference is 0, a lwp can be released
698 */
699void lwp_free(struct rt_lwp* lwp)
700{
701 rt_processgroup_t group = RT_NULL;
702
703 if (lwp == RT_NULL)
704 {
705 return;
706 }
707
708 /**
709 * Brief: Recycle the lwp when reference is cleared
710 *
711 * Note: Critical Section
712 * - lwp (RW. there is no other writer/reader compete with lwp_free, since
713 * all the reference is clear)
714 */
715 LOG_D("lwp free: %p", lwp);
716 rt_free(lwp->exe_file);
717 group = lwp_pgrp_find(lwp_pgid_get_byprocess(lwp));
718 if (group)
719 lwp_pgrp_remove(group, lwp);
720
721 LWP_LOCK(lwp);
722
723 if (lwp->args != RT_NULL)
724 {
725#ifndef ARCH_MM_MMU
726 lwp->args_length = RT_NULL;
727#ifndef ARCH_MM_MPU
728 rt_free(lwp->args);
729#endif /* not defined ARCH_MM_MPU */
730#endif /* ARCH_MM_MMU */
731 lwp->args = RT_NULL;
732 }
733
734 lwp_user_object_clear(lwp);
735 lwp_user_object_lock_destroy(lwp);
736
737 /* free data section */
738 if (lwp->data_entry != RT_NULL)
739 {
740#ifdef ARCH_MM_MMU
741 rt_free_align(lwp->data_entry);
742#else
743#ifdef ARCH_MM_MPU
744 rt_lwp_umap_user(lwp, lwp->text_entry, 0);
745 rt_lwp_free_user(lwp, lwp->data_entry, lwp->data_size);
746#else
747 rt_free_align(lwp->data_entry);
748#endif /* ARCH_MM_MPU */
749#endif /* ARCH_MM_MMU */
750 lwp->data_entry = RT_NULL;
751 }
752
753 /* free text section */
754 if (lwp->lwp_type == LWP_TYPE_DYN_ADDR)
755 {
756 if (lwp->text_entry)

Callers 1

lwp_ref_decFunction · 0.85

Calls 10

rt_freeFunction · 0.85
lwp_pgrp_findFunction · 0.85
lwp_pgid_get_byprocessFunction · 0.85
lwp_pgrp_removeFunction · 0.85
lwp_user_object_clearFunction · 0.85
rt_free_alignFunction · 0.85
lwp_unmap_user_spaceFunction · 0.85
timer_list_freeFunction · 0.85
rt_mutex_detachFunction · 0.85

Tested by

no test coverage detected