Argument Passing

The process_execute function is used to create new user processes in Pintos. Currently, it does not support command-line arguments. You must implement argument passing such that the main function of the user process will receive the appropriate argc and argv. For instance, if you called process_execute("ls -ahl"), the user program would receive 2 as argc and ["ls", "-ahl"] as argv.

Many of our PintOS test programs start by printing out their own name (i.e. argv[0]). Since argument passing has not yet been implemented, all of these programs will crash when they access argv[0].

Until you implement argument passing, most test programs will instantly fail with a kernel PANIC.

For a possible way to implement argument passing, please refer to the Program Startup section in the PintOS documentation. You can also draw on your experience you collected while implementing Assignment 0 where you have split a given input into words. Splitting the given command line into arguments is very similar indeed.

The code needed should be integrated with the start_process function in the file src/userprog/process.c.

Besides splitting the whole command line (as passed to start_process using the file_name_ argument) you will have to independently extract the name of the launched executable (everything before the first non-whitespace character in the buffer pointed to by file_name_) in order for the load function to be able to load the binary code.

Once you have properly implemented argument passing only the following tests (run make check) are allowed to fail with a kernel PANIC: sc-bad-sp, sc-boundary-3, fp-kasm, and fp-kinit. Many other tests will still fail because of missing output, though. The tests do-nothing and stack-align-0 should pass. The reason for the test failures is that you will need to at least implement the write syscall as described here for the tests to be able to write their diagnostics to the console.

The next task for this project is described here: Process Control Syscalls.