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

Function lwp_terminate

components/lwp/lwp_pid.c:1938–1963  ·  view source on GitHub ↗

* @brief Terminates a lightweight process (LWP) * * @param[in,out] lwp Pointer to the lightweight process structure to terminate * * @note Safely terminates an LWP by marking it as terminated, waiting for sibling threads, * and cleaning up resources. */

Source from the content-addressed store, hash-verified

1936 * and cleaning up resources.
1937 */
1938void lwp_terminate(struct rt_lwp *lwp)
1939{
1940 if (!lwp)
1941 {
1942 /* kernel thread not support */
1943 return;
1944 }
1945
1946 LOG_D("%s(lwp=%p \"%s\")", __func__, lwp, lwp->cmd);
1947
1948 LWP_LOCK(lwp);
1949
1950 if (!lwp->terminated)
1951 {
1952 /* stop the receiving of signals */
1953 lwp->terminated = RT_TRUE;
1954 LWP_UNLOCK(lwp);
1955
1956 _wait_sibling_exit(lwp, rt_thread_self());
1957 _resr_cleanup(lwp);
1958 }
1959 else
1960 {
1961 LWP_UNLOCK(lwp);
1962 }
1963}
1964
1965/**
1966 * @brief Waits for sibling threads to exit during process termination

Callers 2

lwp_exitFunction · 0.85
lwp_thread_exitFunction · 0.85

Calls 3

_wait_sibling_exitFunction · 0.85
rt_thread_selfFunction · 0.85
_resr_cleanupFunction · 0.85

Tested by

no test coverage detected