COS 318 : Operating system
Fall 2002, Princeton University

Project 4: Preemptive Scheduling

Important Dates:

Due: 11:59 PM Tuesday, November 19

The goal of this project is to design and implement a simple multiprogramming kernel with a preemptive scheduler. Although the kernel will be very primitive, you will be dealing with several main mechanisms and apply techniques that are important for building multiprogrammed operating systems.

The kernel of this project and future projects supports both processes and threads. Note that the processes in this project are different from those in traditional operating systems (like Unix). Our processes have their own protection domains, but they share a flat address space. In the future, we will be providing processes with separate address spaces. The main difference between processes and threads in this project is that a process resides in a separate object file so that it cannot address data in another process, whereas threads are linked together with the kernel in a single object file.

From now on, the kernel will use the protected mode of the x86 processors instead of the real mode. In this project, everything runs in kernel mode. You are required to do the following:

You should use the code available in the class webpage as a starting point for your project. We provide you with 19 files. Don't be daunted by the large number of files since you are already familiar with many of them and also most files do not require to be touched at all. Only two files need to be changed and their names are in bold face.

Since our entire project will be using the floppy drive, please do not read/modify the hard disk.


Detailed Requirements and Hints

This project continues using the protected-mode of the CPU and run your code in the kernel-mode flat address space. To implement preemptive scheduling, you need to use the timer interrupt mechanism. We have prepared for you the code that is required to set up the interrupt descriptor tables (IDTs) and set up the timer chip. Your job is to decide what goes into the interrupt handler.

You need to figure out where you can perform preemptive scheduling. You need to review the techniques discussed in class. Note that in this project, you can disable interrupts, but you should avoid disabling interrupts for long a period of time or indefinitely. In order for processes to make system calls, you will note that the code in syslib.c does not make a function call, rather it invokes a software interrupt. The kernel threads should still work in the same way as before, calling the functions in the kernel directly.

To implement condition variables, you will need to add two new calls in the kernel (the code will end up in thread.c). Also, both condition variable calls and mutual exclusion calls should work correctly in the presence of preemptive scheduling. You need again to review the techniques discussed in class.

Extra Credit

You will get an extra point if you implement priority scheduling and demonstrate it with processes provided by us.

Useful Resources


Submitting Programming Assignments

Submit your final solution electronically using the following command:

/u/cs318/bin/318submit 4 README otherfiles ...

The submit command copies your files to the directory /u/cs318/submit/UserLogin/number and lists all the files that you have submitted for assignment number. UserLogin is your user account name. If you execute submit after the project deadline, your files are placed in directory number_late. You can run submit more than once, and you can submit partial lists of files.


CS318 Staff