COMP 242 - Spring 02

Process Management (Due Tue Jan 29)

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.

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 Pentium 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 can search the web for information about Pentium assembly language. Two links I found are: Ghoshal's notes and Smoler's notes . You should build on top of a Unix-based OS for the PC- FreeBSD or Linux. We have allocated some FreeBSD machines in the Colab (Rm 155) for this course, to which you can rlogin. Look at the general discussion forum for information on these machines. If you have more convenient access to some other Unix PC, go ahead and use it. (You can cleanly implement some but not all assignments on top of a Windows-based OS.)

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 may 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 all other assignments, prefix all Xinu system calls with "xinu_". Thus kill() of Xinu should be called xinu_kill() in your system. This will distinguish them from Unix calls such as kill() with the same name. If you do not do so, you will get subtle errors in future assignments. Also, make sure you allocate a large stack space (say 4K) for the processes you create, otherwise you will get subtle problems because of stack overflow.

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. You will be graded on both the functionality you implement and the test program you create. I will post grading sheets detailing the functionality that should be tested a few days before the assignment is due. The test programs will be graded on

When (a) and (b) conflict with (c), give precedence to (c). For this and future assignments, make an appointment with me to demonstrate your solution - ideally it should be done during office hours of the day the assignment is due.

In addition to demonstrating your solution, you should submit written answers to the following questions:

1) Unlike the LSI implementation, the Pentium implementation does not store the registers to be saved in the context block. Where does it store them?

2) Unlike the LSI implementation, the Pentium implementation does not store the PC in the register save area. The saved PC, in the LSI implementation, is used to ensure (a) a new process starts correctly (at the start of its procedure) and (b) control is transferred to the correct location after a context switch. Explain how these two goals are achieved in the Pentium implementation. (Hint: Compare the ctxsw and create in the two versions.)

Two weeks is probably more time than you need for the assignment - implement it as quickly as you can. I will post the next assignment before the due date for this assignment so that you can get an early start.