Comment on page
Process and Memory
Xv6 time-share processes. Save its CPU registers when process not running, and restoring them back when it resumes. Process can create another process using
waitreturns the pid of the exited child of the current process.
waitwaits until one child to exit.
Parent process and child process are executing with different memory and different registers. Changing a value does not affect another.
execsystem call replaces the calling process’ memory with a new memory image loaded from a file. The file is ELF format.
Xv6 Shell calls
getcmdto reads a line of user input, then call
fork, which creates a copy of the shell process. The parents calls
wait, while the child is running the command.
Process wants more memory could call
If they are separate, the shell can fork a child, use open, close, dup in the child to change the standard input and output file descriptors, and then exec! Executed program does not need to understand how to redirect I/O. It is simple.