COMP 242 - Fall 97

Process Management (Due Tue Sep 16)

The goal for this assignment is to implement process management. Specifically, you need to implement the semantics of the Xinu routines, resume, suspend, create, kill, and resched. You can assume that create takes only integer arguments. Instead of implementing processes directly on the hardware, you will implement ``light weight processes'' within a heavyweight UNIX process- your kernel routines and all the processes you create will execute as part of a single UNIX process. Unlike the Xinu routines, your routines do not currently need to worry about about interrupts. However, do write your routines in a modular fashion, since subsequent assignments will build on the ``micro kernel'' you implement as part of this assignment.

One difference between your kernel and Xinu is that the former will start executing the Unix main procedure while the latter starts executing an assembly routine called `start', which in turn calls the C routine, nulluser, which then forks the process executing the main procedure. (Look at the implementation of nulluser and sysinit in Chapter 13 of the Xinu book to see how a single program is transformed into an operating system.) Assume that the programmer provides a special procedure called xinu_main, which corresponds to the main routine in a Xinu program. The Unix main procedure, thus, initializes the kernel state and then uses Xinu create to fork a process executing xinu_main. Also, while Xinu process management uses Xinu getmem for allocating memory, you can simply use Unix malloc.

Much of your implementation effort will involve simply including Xinu code into a Unix process. The course home page included a pointer to the Xinu source code , which you can include in your assignment. (Thus design is less of an issue in this assignment than in others.) You are free to choose whether you want to follow the Xinu code structure. In particular, you are free to use C++ and object-oriented concepts to implement the code. (For instance, a process table entry can be made an object that responds to messages such as create, suspend, and kill.) However, if you are unfamiliar with object-oriented or other novel programming concepts you would like to use, do not use this class to learn them. So many things can wrong in your coding that you should not have to worry about overcoming new programming concepts.

You should not not use the set jump feature provided by C and instead do your own saving/restoring of registers in ctxsw.

The PCs are still unstable so the TA has not been able to test an implementation on the Intel architecture. He may be able to do so this weekend. Since we do not want to delay the start if the assignment, we will accept implementations on the Dec MIPS architecture. In fact, the rest of the handout assumes this. As we figure the PC environment, we will give you more information for those who want to wait a few days before committing their code.

Since ctxsw manipulates registers, you will need to write it in MIPS assembly, which is described in the MIPS handout. Look carefully at the examples in the handout that show how to define an external assembly routine that can be called from a C program. There are many differences between the MIPS architecture and LSI-11 architecture described in the book - for instance, in the MIPS architecture there are both (8 byte) floating and (4 byte) integer registers, the return address and some arguments are stored in registers, and the target of a jump must be in a register. You can assume that one register does not have to be saved in the context block. It should be a temporary register (such as $15) that is also not saved across procedure calls. Include the file, regdef.h, so that you can use symbolic names for the registers.

You may also want to look at Sid Chatterjee's handout for a concise summary of the MIPS architecture which he gave to his complier class. It does not address floating point registers, which can be saved and loaded like integer registers. (Instead of using ``lw'' and ``sw'', you use ``l.d'' and ``s.d'', respectively.) Also, while Sid's handout describes the mfhi and mflo instructions for saving HI and LO, it does not mention the converse, mthi and mtlo instructions for loading HI and LO. The one page summary I got from Tom White addresses parameter passing. Note that though some arguments are passed in registers, you must allocate stack space for and save all arguments on the stack. Finally, you can look at Sid Chatterjee's RISC page for a complete description of the MIPS architecture.

When you get this assignment, we probably will not have covered all the Xinu routines you need to implement. In the meantime, you can study MIPS assembly and also implement and test the Xinu Queue routines, which you will need in this assignment. You may also want to look ahead at the process management routines so that you can get an early start.

For this and subsequent assignments, you are free to discuss the machine, programming environment and high-level algorithms with other students but you are required to code your programs individually. It is your responsibility to test the program. You should submit the test results with your program and an outline describing the main differences between your program and Xinu. You will be graded on both the functionality you implement and the test data you submit. The TA may run additional tests to check untested functionality.