CS 39 Fall 2001 -- Project 1


A note on Academic Honesty

For these assignments, you are allowed to discuss the problem, and your thoughts on the solution, with others. You are not allowed to exchange, in any way, code or anything like it.

Because you will be working in teams, and those teams are likely to be working in the Sun Lab at the same time, there will be a good deal of discussion. Be sure that your team's work is its own!

If you have questions about what might or might not be acceptable, ask before acting.


Supporting multiple processes

We will be using a virtual platform, which is the combination of a virtual machine (which is really a simulated, simple CPU architecture) and a kernel that controls that machine.

The current virtual platform is capable of booting the kernel, which in turn loads a single executable image, executing that one process, and then halting. While there is a good deal of machinery involved in this simple platform, it does not do as much as we would like.

Most specifically, we would like the kernel to be able to load and interleave the execution of multiple processes. That is, when the virtual platform is started, two or more programs can be specified (some programs perhaps more than once).


Your assignment (specifically)

Go to the course web page and select the Projects section. Follow the link to the Getting Started page. It will provide instructions on how to download and start using the Virtual Platform. You can read the Getting Started document to get familiar (again, for some) with obtaining the code for the assignment, compiling it, and working on it with xemacs and gdb.

The following points should describe what you need to do:

  1. In its initial state, the virtual platform works, but with one exception -- it may crash if a clock interrupt occurs, as the kernel doesn't know how to handle that yet. You must make the kernel set clock interrupts to occur on a regular basis, and then handle those interrupts within the kernel.
  2. You will need to modify the kernel to load multiple executable images, and create processes for each. Note that there are currently no data structures to keep track of processes in the kernel -- that's up to you!
  3. In its current form, the virtual machine supports protection on address ranges (with base and limit registers) so that the kernel can keep processes from accessing one another's memory. You must, in creating and loading these processes, allocate memory space for each one.
  4. The execution of these processes should be interleaved -- that is, your kernel should have a short-term scheduler that switches between processes at every clock interrupt. Note that register interruptPeriod allows the kernel to set its quanta. Be sure to make your quanta small enough to demonstrate the interleaving of your processes.
  5. Processes should be able to perform a FORK system call. Create this system call within your kernel, such that a process that forks has all of its resources (read: address space) duplicated as a copy. Note that there is an enumeration of the system calls in systemCall_t, near the front of kernel.cc. The FORK call should be assigned the constant 0x11111110. The FORK call should return (via generalRegister[0x1F]):
    1. The child process ID to the parent process.
    2. The value 0 (zero) to the child process.
    Note that we will not worry about an EXEC facility just now -- these will be two copies of the same process, running along happily to completion.

It is important to note that no changes to the virtual machine are needed. There may be bugs in the virtual machine, but if there are, you should contact me! I will plan to compile your kernel along with my virtual machine, and they should work together!


Submitting your work

Soon, you will have a group project directory in which to work. All of your work should be done in that project directory. If you are a member of group E, then you are part of the UNIX group cs39e, and can share files with other people in your group in the directory:

/student/projects/cs39/e

When your group has completed its project, it should gather all of the files that are part of the completed project, and place a copy of those files in a directory named project-1 within your group's project directory. I will go and find them there.

This project is due on Friday, September 28th at 11:59 pm!

Scott F. Kaplan
Last modified: Wed Sep 19 15:01:37 EDT 2001