Skip to content

Comments

Xv6 new system calls addition#424

Open
Rahul-069 wants to merge 3 commits intomit-pdos:riscvfrom
Rahul-069:xv6-system-calls-addition
Open

Xv6 new system calls addition#424
Rahul-069 wants to merge 3 commits intomit-pdos:riscvfrom
Rahul-069:xv6-system-calls-addition

Conversation

@Rahul-069
Copy link

Overview

This pull request adds three new system calls to xv6-riscv, enhancing process creation and parent-child process interaction.

System Calls Implemented

  1. forkwitharg() – Creates a new process and allows passing an argument from parent to child.
  2. getforkarg() – Retrieves the argument passed using forkwitharg().
  3. getppid() – Returns the parent process ID of the calling process.

Files Modified

  • kernel/syscall.h – Added new syscall identifiers (SYS_forkwitharg, SYS_getforkarg, SYS_getppid)
  • kernel/proc.h – Added a new field fork_arg to the struct proc
  • kernel/proc.c – Implemented logic for forkwitharg to handle argument passing
  • kernel/sysproc.c – Added sys_forkwitharg, sys_getforkarg, sys_getppid syscall handlers
  • kernel/defs.h – Declared prototypes for the new system calls
  • kernel/syscall.c – Linked new system calls in the syscall table
  • user/user.h – Declared the new system calls for user-space programs
  • user/usys.pl – Added entries for forkwitharg, getforkarg, and getppid
  • user/fork.c – User program demonstrating the use of the new system calls
  • Makefile – Added the user program fork to the compilation list

Testing

  • Verified functionality using the fork user program.
  • All system calls execute correctly under QEMU.
  • Existing xv6 functionality remains unaffected.

@djhayman
Copy link

djhayman commented Jan 27, 2026

Your code seems to have changed the line endings of all the files you touched, and the last new line you added to kernel/defs.h has incorrect indentation. And sys_getppid should not have been added to kernel/defs.h.

But ignoring formatting issues, what problem does sys_getforkarg solve? The int arg variable is already immediately available in the forked child process, your new code doesn't actually add anything new.

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

Successfully merging this pull request may close these issues.

2 participants