Write a simulation to analyze CPU scheduling algorithms. You will simulate the following schedulers:
First Come First Serve
Shortest Job First (non-preemptive and preemptive)
Priority (non-preemptive and preemptive)
Round Robin with q=50.
Round Robin with q=10
You may write your program in the programming language of your choice, but I must be able to run it from the Suns or my PC.
Your program will need to specify an input filename from the command line and a single flag. The flag is optional on the command line. If it is specified, your program will produce verbose output (see below), otherwise it will produce the default output only.
Suppose you write a program called CPUSim. The command line format would be:
CPUSim infile -vor
java CPUSim infile -vwhere infile is the name of the file from which to read and the optional -v specifies verbose output.
Your program will read processes from a file. The first line of the file will contain n:the number of processes to simulate which will have a value between 1 and 1000.
There will then be n lines (one for each process) containing 4 integers separated by a single space:
5 1 1 5 65 2 1 10 73 3 1 15 17 4 7 20 128 35 5 25 2
Your code should be readable and understandable. To facilitate this you should include detailed comments about your code. You should include two varieties of comments. The standard mechanical comments will indicating what code is doing, what parameters/return values mean etc.
You will also include thematic comments. These thematic comments will describe in general terms the activities and events surrounding the "process" structure in your simulation. Document what is done to the processes, how they are manipulated, how they change. If your code tells a story, the process is the protagonist.
Thematic comments should begin with a "--". So in Java and C++ you would use //-- or /*-- to indicate the beginning of a thematic comment.
A week after the program is due, you will turn in a report. The report will be a short (2 to 3 page) analysis of your results. This should include some experimentation. Build small datasets (10 to 20 processes) that produce interesting behavior in your simulation. What makes one scheduler better than another? Are there situations where two schedulers work identically?
Your report should include a brief discussion of your simulation. What design decisions did you have to make? Were there any that you feel affected the final results? Would you make a different decision if you had to do it again?
Your grade for the report will be determined by both the content and presentation of your analysis.