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

Possibly redundant myproc call in exec? #322

Open
LIParadise opened this issue Mar 2, 2025 · 1 comment
Open

Possibly redundant myproc call in exec? #322

LIParadise opened this issue Mar 2, 2025 · 1 comment

Comments

@LIParadise
Copy link

Here in kernel/exec.c we called myproc, which we've already done just now at this line.

AFAIK since the XV6's processes are managed by the global array struct proc proc[NPROC] in the kernel, that end_op, e.t.c., may sleep and thus change the CPU on which this call is carried out should not invalidate the struct proc*.

In fact the chapter 7.4 of the XV6 book rev.3 mentions that the pointer returned by myproc is safe to use even if some interrupt causes the process to be moved to other CPU, and the XV6 exec implementation on x86 does only call myproc once.

Are there any soundness concerns for the second call to myproc here?

Best Regards

@jrmenzel
Copy link

jrmenzel commented Mar 7, 2025

In my fork of xv6 I only query the process once: https://github.com/jrmenzel/vimix_os/blob/184435c55764d1f59421735b0542993f40db9c26/kernel/kernel/exec.c#L82
Never had any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants