* @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. */
| 1936 | * and cleaning up resources. |
| 1937 | */ |
| 1938 | void 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 |
no test coverage detected