CS215

Assignment #9 (Fourth Programming Project, Second Part)


DUE: Monday, 12/8/2014

This project is the continuation and conclusion of Assignment 7.

The goal is to simulate a CPU scheduler with multilevel feedback queues using Java threads. For simplicity's sake, create 3 separate queues for handling 6 processes, where each process is represented by a thread. The queues represent different priorities, where processes with short CPU bursts are favored in the higher levels.

Assign different, increasing quanta to the three queues; one scheme might be for the quantum at level n+1 to be twice that of level n. The scheduling discipline will follow the one described in the text. That is, if a process completes its CPU burst before a quantum runs out, it is put back on the same queue for its next CPU burst. If, on the other hand, it runs to the end of a quantum before its CPU burst is complete, it is placed on a lower level queue. The lowest level queue works according to FCFS. No process is dispatched from a lower level queue unless all the higher-level queues are empty.

Of course, this will inevitably lead to starvation. There are several ways around that. The preferred technique will be to age processes according to their response ratios. Periodically, the scheduler thread should run through the processes in the lower-level queues and update their response ratios. If any process's response ratio gets above a certain threshold, it should be bumped up to a higher queue.

CPU bursts must be randomly generated. For example, you may assign a high probability to a small burst, a modestly lower probability for a larger burst, and a quite small probability for a very large burst. Other distributions are possible. Of course, this continues the requirements of Assignment 7, and again implies that a process running to the end of its CPU burst within a quantum must wake up the scheduler.

Provide a graphical user interface, drawing on your experience with Assignment 3, that will allow the user to visualize the simulation. One way of doing this would be to provide TextFields for each of the elements of the queues and each of the processes, showing the remaining number of iterations in their CPU bursts. A TextField should also display the currently running process, and there should be a button for starting and stopping the simulation (which again entails some interesting synchronization problems).

A good place to begin development might be with multi-level queues without feedback, and without random CPU bursts. That is, for example, put 2 threads on each of the three queues, so you have a total of 6. In this case, each thread would be permanently associated to one queue.

This assignment is intentionally open-ended, to allow you to exercise some creativity as well as to encourage experimentation. There are, in particular, many parameters to experiment with, e.g., the distribution of CPU burst lengths, the size of the quantum in the top queue, the relative size of the quanta in the lower queues, and how aging is handled. It would also be quite interesting (and more realistic) to allow a process to leave the queueing system for a time (e.g., by putting its corresponding thread to sleep), to model waiting for I/O. There are also a number of quantities to measure over the course of a simulation, in particular response time, turnaround time, and waiting time. Highest grades will go to those (working) projects that present a rich set of features.

Back to CS215 Home Page