summaryrefslogtreecommitdiff
path: root/components/lwp/lwp_pid.c
AgeCommit message (Collapse)Author
2026-05-26lwp: fix pid leak on exec failure before task startupyang.zhang
When msh tries to execute a non-ELF path, lwp_execve() may allocate a PID before lwp_load() fails. The old error path only dropped the LWP reference, leaving the PID tree entry pointing to a freed LWP. In an init-less boot flow, this can poison pid 1 after a failed command from msh. A later LWP launch may then treat the stale pid 1 entry as a valid parent LWP, resulting in invalid pgrp/session state and a job-control assertion during process exit. Add lwp_pid_rollback() for exec/spawn failures before the process becomes runnable. Unlike lwp_pid_put(), it always releases the PID lock and does not enter the "no more pid allocation" state when the PID tree becomes empty. Use the rollback helper in lwp_execve() failure paths after PID allocation. Signed-off-by: zhangyang <[email protected]>
2025-09-19[components/lwp]add doxygen comment for lwp_pid. #10702Guorui Li
2025-01-21[lwp]修正无法通过文件名查找pid的问题 (#9935)heyuanjie87
2025-01-06feat: add system reboot and process teardown supportShell
The patch introduces support for system reboot functionality and process teardown, allowing for a clean shutdown and unmounting of the root filesystem. This is necessary for ensuring a proper system shutdown process, especially when dealing with resource cleanup and ensuring that all processes have exited before system shutdown. Changes: - Added `lwp_teardown()` function to handle process cleanup and system teardown. - Introduced `lwp_pid_wait_for_empty()` to wait for process ID table emptiness before proceeding with shutdown. - Updated `dfs_mnt_unref()` to trigger callbacks when unmounting a filesystem. - Added new reboot types (`RB_AUTOBOOT`, `RB_POWER_OFF`) and implemented their corresponding actions, including cleanup of processes and unmounting root filesystem. - Extended `sys_reboot()` to handle reboot and power off types with appropriate callbacks for process and filesystem teardown. - Introduced callback mechanism for root filesystem unmount notifications. Signed-off-by: Shell <[email protected]>
2025-01-06feat: support PID iterationShell
This change introduces the `lwp_pid_for_each` function, which provides a convenient and thread-safe method for iterating over PIDs with a user- defined callback. This addition is necessary to support cases where operations must be performed on each PID in the balanced tree, enhancing flexibility and modularity for PID management. Changes: - Added `lwp_pid_for_each` function in `lwp_pid.c` to allow iteration over PIDs using a callback function and optional data parameter. - Defined a new internal `pid_foreach_param` structure to encapsulate the callback and data for the iteration. - Added `_before_cb` helper function for executing the callback on each PID node during AVL traversal. - Ensured thread safety by acquiring and releasing the PID lock around the AVL traversal within `lwp_pid_for_each`. - Updated `lwp_pid.h` with the `lwp_pid_for_each` function prototype and included `rtthread.h` for necessary types. Signed-off-by: Shell <[email protected]>
2024-05-31[lwp]list_process can print tid (#8991)rcitachi
* list_process can print tid * fix-ci * update list_process * Update lwp_pid.c
2024-05-29[smart] update sched_setaffinity() to use thread(task) ID (#9004)Shell
Correct `sched_setaffinity()` to use the thread IDs (TIDs) instead of process IDs (PIDs). The previous implementation used PIDs, which caused issues since affinity settings need to be applied at the thread level. As the manual documented, the signature is: > int sched_setaffinity(pid_t pid, size_t cpusetsize, > const cpu_set_t *mask); Yes, it's tricky, the identification passing in is called **'PID'**. But when we talk about 'pid' from GNU libc, it's the **'task-id'**, aka, `thread->tid` known in kernel. Changes were made by updating the function signatures and logic in `lwp.h`, `lwp_pid.c`, and `lwp_syscall.c` to accept TIDs. Specifically, the `lwp_setaffinity` function and related internal functions now operate using thread IDs and adjust thread affinity settings accordingly Signed-off-by: Shell <[email protected]>
2024-05-21[quality] fixup compiler warning (#8961)Shell
Signed-off-by: Shell <[email protected]>
2024-03-28sync smart & dfs (#8672)Shell
Signed-off-by: xqyjlj <[email protected]> Signed-off-by: Shell <[email protected]> Co-authored-by: xqyjlj <[email protected]>
2024-02-23🎯 Sync smart & scheduler codes (#8537)Shell
Signed-off-by: Shell <[email protected]> Co-authored-by: xqyjlj <[email protected]>
2023-11-06✨ feat: fix pid recycling (#8225)xqyjlj
2023-11-02🐞 fix: fix taskset (#8211)xqyjlj
2023-11-02[smart] fixup of lwp recycling and mm varea (#8206)Shell
Signed-off-by: shell <[email protected]> Signed-off-by: Shell <[email protected]> Co-authored-by: xqyjlj <[email protected]>
2023-10-25🎈 perf: perf rt_hw_interrupt_disable/enable (#8042)xqyjlj
Signed-off-by: Shell <[email protected]> Co-authored-by: Shell <[email protected]>
2023-10-17Sync dfs lwp (#8123)geniusgogo
2023-10-14[smart] Replace irq disable/enable codes in futex (#7941)Shell
Signed-off-by: Shell <[email protected]>
2023-10-13[smart] fixup: lwp_free() (#8126)Shell
Signed-off-by: shell <[email protected]>
2023-10-11[smart] split out part of lwp_new() to lwp_create()Shell
Prev implementation of lwp_new() including the create of lwp object and the pid allocation. But not every lwp object need a pid. So this patch split out the business of lwp_new() to improve the maintainability. Signed-off-by: Shell <[email protected]>
2023-09-22[smart] fix of cmd_kill (#8071)Shell
Signed-off-by: Shell <[email protected]>
2023-09-09[smart] add waitpid(-1) support (#8020)Shell
Signed-off-by: shell <[email protected]>
2023-08-12fix lwp_free tty switch to foreground error (#7945)geniusgogo
2023-08-07update components & lwp. (#7888)geniusgogo
2023-08-03[smart] Fix bugs on lwp kill (#7892)Shell
Signed-off-by: Shell <[email protected]>
2023-07-22[smart] fix possible memory leak (#7832)Shell
Signed-off-by: Shell <[email protected]>
2023-07-20[component/lwp] support more feature of signal from IEEE Std 1003.1-2017 (#7828)Shell
Signed-off-by: Shell <[email protected]>
2023-06-29[components/lwp] clear ref to parent on waitpid() (#7741)Shell
Signed-off-by: shell <[email protected]>
2023-04-08[DFS] prepare for dfs_v2.0 (#7200)Bernard Xiong
* [DFS] prepare for dfs_v2. dfs_fd -> dfs_file; dfs_fnode -> dfs_vnode. * [BSP] fix code analysis warning * [smart] fix the pointer overflow. * code format * [smart] fix the lwp->lwp_obj checking.
2023-04-04[kernel] 将rt_thread结构体改为显式继承rt_object (#7131)Shicheng Chu
2023-02-21[fixup] add cache maintenance ops;wangxiaoyao
fix bugs on cache maintenance when starting user app
2023-01-13[rt-smart][fix/lwp] don't restore terminal for background lwp (#6847)Shell
* [fix/lwp] don't restore term for background lwp
2022-12-16[rt-smart] 弱化 RT_USING_LWP,使用 RT_USING_SMART 作为宏配置 (#6740)guo
* [dfs] sync cromfs * [rt-smart]Weaken RT_USING_LWP, use RT_USING_SMART as macro configuration * [format] fix some format issue.
2022-12-03sync branch rt-smart. (#6641)guo
* Synchronize the code of the rt mart branch to the master branch. * TTY device * Add lwP code from rt-smart * Add vnode in DFS, but DFS will be re-write for rt-smart * There are three libcpu for rt-smart: * arm/cortex-a, arm/aarch64 * riscv64 Co-authored-by: Rbb666 <[email protected]> Co-authored-by: zhkag <[email protected]>