MCPcopy Index your code
hub / github.com/RT-Thread/rt-thread / lwp_thread_exit

Function lwp_thread_exit

components/lwp/lwp_pid.c:913–947  ·  view source on GitHub ↗

* @brief Handles thread exit for a lightweight process * * @param[in,out] thread The thread that is exiting * @param[in] status The exit status to set for the thread * * @note For MMU architectures, this function checks if the exiting thread is the * header thread (main thread). If so, it treats it as a process exit. */

Source from the content-addressed store, hash-verified

911 * header thread (main thread). If so, it treats it as a process exit.
912 */
913void lwp_thread_exit(rt_thread_t thread, int status)
914{
915 rt_thread_t header_thr;
916 struct rt_lwp *lwp;
917
918 LOG_D("%s", __func__);
919
920 RT_ASSERT(thread == rt_thread_self());
921 lwp = (struct rt_lwp *)thread->lwp;
922 RT_ASSERT(lwp != RT_NULL);
923
924#ifdef ARCH_MM_MMU
925 _clear_child_tid(thread);
926
927 LWP_LOCK(lwp);
928 header_thr = rt_list_entry(lwp->t_grp.prev, struct rt_thread, sibling);
929 if (header_thr == thread && thread->sibling.prev == &lwp->t_grp)
930 {
931 /**
932 * if thread exit, treated as process exit normally.
933 * This is reasonable since trap event is exited through lwp_exit()
934 */
935 lwp->lwp_status = LWP_CREATE_STAT_EXIT(status);
936 LWP_UNLOCK(lwp);
937
938 lwp_terminate(lwp);
939 }
940 else
941 {
942 LWP_UNLOCK(lwp);
943 }
944#endif /* ARCH_MM_MMU */
945
946 _thread_exit(lwp, thread);
947}
948
949/**
950 * @brief Increments the reference count of a lightweight process

Callers 1

sys_exitFunction · 0.85

Calls 4

rt_thread_selfFunction · 0.85
_clear_child_tidFunction · 0.85
lwp_terminateFunction · 0.85
_thread_exitFunction · 0.70

Tested by

no test coverage detected