COSC 374
Operating Systems
Spring 2002
Programming Project #1

Assigned: Tuesday, January 29, 2002
Design Due: 1:14 P.M., Tuesday, February 5th, 2002.
Project Due: 1:14 P.M., Thursday, February 14th, 2002.

Goals

There are two main goals for this project: You should also read over the general project information page before you start this project. In it, you'll find  information about the DLXOS system as well as general guidelines and hints for projects in this class.

Details

In this project, you will modify the scheduler for DLXOS. This should only involve modifying code in process.c and process.h, though you may want to look at other modules to see how they fit together (you may, of course, modify code elsewhere if you wish).

Choosing a scheduling algorithm

You should pass an argument to the operating system (-S n) that determines the scheduling algorithm (see the code in main() for hints on how to pass arguments to the operating system at startup). The algorithm may not change during operating system execution. The algorithms are:

Dual round robin queues

The first algorithm you need to implement uses two round robin queues. Processes are placed into the first queue when they are created, and move to the second queue after they have had five quanta (i.e., they have been scheduled five times). The scheduler runs all of the processes in the first queue once and then runs a single process from the second queue. This can be implemented in several ways; one possibility is to include a "pseudo-process" in the first queue that, when at the front of the queue, causes a process from the second queue to be run.

Assume the following processes are in the two queues:

Queue 1: P1 P2 P3
Queue 2: P4 P5 P6 P7

The scheduler would run processes in this order:

P1 P2 P3 P4 P1 P2 P3 P5 P1 P2 P3 P6 ...

This allows long-running processes to make (slow) progress, but gives high priority to short-running processes.

Priority-based scheduling

For this algorithm, the scheduler always selects the highest-priority process in the ready queue. A process's priority is set with ProcessSetPriority (int processID, int n), which you will have to write. Higher values of n mean a higher priority. If there are several processes with a particular priority, they are selected round-robin (they should receive approximately equal slices of CPU time). You may implement this algorithm using a single queue, scanning down it for the highest-priority process, or you may use multiple queues. It is likely, however, that it will be easier to implement using a single queue.

Note that a process's priority may change during execution if ProcessSetPriority() is called.

Extra credit

You may receive extra credit for implementing dynamic priority assignment (5 points). However, you can only receive extra credit if the required portion of the project is working. In other words, do the required assignment first. Also, your extra code shouldn't break your required code; we strongly suggest that you use a revision control system (such as RCS) to make sure you keep a working version of your code.

For dynamic priority assignment, you should modify priority scheduling to multiply a process's priority by 0.90 each time it receives a full quantum, and increase its priority by 1 each time it blocks without exhausting its quantum. A process's priority should never drop below 1, and should never exceed its original (desired) priority.

Hints

Working on the project

We assume that you are already familiar with makefiles and debugging from earlier classes. If not, this will be a considerably more difficult project because you will have to learn to use these tools as well.

This project doesn't require a lot of coding (probably less than 100 lines), but does require that you understand what's going on inside the operating system and how to use the DLX simulator and compilation tools. You're encouraged to talk to others in the class or visit the professor's office hours to get help if you need it. Remember, while it is allowed to discuss the general solution of the project, you may not share your actual design document or code with anyone else.

You should do your design first, before writing your code. To do this, compile and run the operating system, inserting debugging print statements if you like. It may be more "fun" to just start coding without a design, but it'll also result in spending more time than you need to on the project.

IMPORTANT: As with all of the projects this quarter, the key to success is starting early. You can always take a break if you finish early, but it's impossible to complete a 20 hour project in the remaining 12 hours before it's due....

What to hand in

As with other projects, you'll need to hand in your design documentation and your code, both of which must be handed in as described on the general project information page.

Grading

I will likely test your code by creating processes and seeing how the scheduler handles them. Thus, please use the function call names and parameters listed in the assignment. If you provide information about how you tested your code (and whether it was successful), I may be able to give you "credit" for things that worked for you even if I find things that don't work with my tests.

Last updated on 28 January 2002, by Clay Shields, from a page by Ethan Miller (elm@cs.ucsc.edu)