20 points
Here is an extra credit assignment for those seeking a further challenge. Only attempt this if you are done with Parts 1 and 2.
If you run the following xv6 program :
#include "types.h"
#include "user.h"
int main() {
printf(1, "hello world!");
return 0;
}
It will actually crash with a message like this:
pid 3 mytest: trap 14 err 5 on cpu 1 eip 0xffffffff addr 0xffffffff--kill proc
xv6 programs are supposed to call the exit() syscall before finishing naturally. That's kind of silly and it's different than standard C. Your extra credit task is to fix this.
Note that a real unix system would make the return status available to parent process. When the program is run from a shell like bash or tcsh, the $? variable stores the return code of the last process. However, xv6's primitive shell does not have any notion of variables, and that's why we're just printing out the return status.