As with the previous parts of the project, implement the code for exec, join, and exit incrementally and test for correctness before moving on to the next feature. For example, you can hold off implementing argument passing until the core functionality of exec works.
This page provides some sample programs that you can use as a basis for writing your own test programs. To start, here is a simple program to test exit:
And a simple program that uses it as a child for exec:
With the basics of exit and exec working, here is a simple program for join:
Once you have the core functionality for these system calls implemented, you can test more advanced functionality. Here is a program to help debug argument handling:
Finally, here is an example program that causes an exception when it executes. You can use this program as a basis for testing cleaning up after processes that encounter an exception:
Testing: The syscall.h file and the project page specify the requirements for the various system calls. For convenience, here we summarize the functionality that test programs should exercise.
exec: creates and runs a new process; each new process gets its own PID; can create multiple processes as long as there is sufficient physical memory; arguments are passed correctly from parent to child; validates parameters (file name, arguments).
exit: open files are closed; physical pages are released so that they can be reused by a later process; the last process to exit calls Kernel.kernel.terminate.
join: join works whether or not child has finished by the time the parent calls join; can only join to a direct child of the parent, otherwise return an error; join returns 0 if the child terminates due to an exception.
halt: Only the root process can successfully halt.