COMP 242 - Spring 00

Process Management (Due Thu Feb 3)

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 . In addition, you should write a procedure, prprint , that will print information about the processes that exist in the system. You should do this by first printing all non-free entries in the process table, and then printing the contents of the Ready list, and the current process. You should print all available information about each process in a neat and orderly fashion, and use the same format for all processes. Finally, you should implement a system call to change the priority of a process. The Xinu implementation, chprio() , has a flaw. Include this implementation in your code. In addition, implement your version, chprio2() , that corrects the bug. You should carefully document the problem, and your solution to it

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.

Thus your implementation effort will involve simply including Xinu code into a Unix process. The course home page includes a pointer to the Xinu source code , which you can include in your assignment. Your implementation should run on a PC - therefore look at the PC version of Xinu. The directories of interest in this assignment are the sys and h directories. Since you are not implementing on top of the bare machine, comment out all calls to disable and restore interrupts.

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.

When you get this assignment, we probably will not have covered all the Xinu routines you need to implement. In the meantime, you can 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. Be sure to write a test program that uses both the original chprio() and your chprio2() and demonstrates the difference. 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.

The Xinu version for the Pentium differs from the one for the LSI in one important respect. Unlike the LSI version, the Pentium one does not store the program counter of the process in the context block. Explain how, in the Pentium version, control is correctly transferrred to another process. Explain what effect this difference has on the various process management routines. (Hint: Compare the ctxsw and create in the two versions.)