Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(process): 调整arch_switch_to_user函数,把riscv和x86_64的共用逻辑抽取出来。 #773

Conversation

fslongjin
Copy link
Member

refactor(process): Extract common logic for riscv and x86_64 in arch_switch_to_user to run_init_process

调整arch_switch_to_user函数,把riscv和x86_64的共用逻辑抽取出来。写成run_init_process函数,并且能够尝试运行多个不同的init程序,直到某个运行成功

…switch_to_user to run_init_process

调整arch_switch_to_user函数,把riscv和x86_64的共用逻辑抽取出来。写成run_init_process函数,并且能够尝试运行多个不同的init程序,直到某个运行成功
@fslongjin fslongjin added the A-process Area: process management label Apr 26, 2024
@fslongjin fslongjin requested a review from GnoCiYeH April 26, 2024 06:26
@dragonosbot
Copy link

r? @Chiichen

dragonosbot has assigned @Chiichen.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@dragonosbot dragonosbot added O-riscv64 Target: riscv64 O-x86_64 Target: x86_64 S-等待审查 Status: 等待assignee以及相关方的审查。 labels Apr 26, 2024

unsafe { arch_switch_to_user(path, argv, envp) };
unsafe { arch_switch_to_user(trap_frame) };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉这个函数的调用在switch_to_user里面更合适,代码功能性区分会更明确一点

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


fn try_to_run_init_process(path: &str) -> Result<(), SystemError> {
if let Err(e) = run_init_process(path.to_string()) {
if e != SystemError::ENOENT {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch_to_user来看,init程序的启动是有优先级的,所以我觉得这里的日志应该更完善一点,提示当前是运行哪个init程序,前面的为什么出错。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

会有报错的,在那个exec那里就会报出错误的

@fslongjin fslongjin merged commit f75cb0f into DragonOS-Community:master Apr 27, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-process Area: process management O-riscv64 Target: riscv64 O-x86_64 Target: x86_64 S-等待审查 Status: 等待assignee以及相关方的审查。
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants