CIS332 (Spring 1999) Principles of Operating Systems;
Professor Franz J. Kurfess

Homework Task Deadline Points Student Name:
6 CPU Scheduling Implementation Monday, Oct 19, 1998 20

Write a program in C or C++ that implements First-Come, First-Served (FCFS) and Round-Robin (RR) CPU scheduling algorithms. Your program should be able to read input from a file. The format of the input file is given below. Your program will be tested using different sets of data.

P1	0	15	Note : First column - Process number
P2	10	28		Second column - Arrival time
P3	14	7		Third column - Burst length
P4	25	32
P5	43	18

Addendum to Programming Assignment:

The name of the input file should be  'data'.
If you are using C, you may like to include the following to open an input file
with the above name :
 
            ..............
            FILE *input_file;
            input_file= fopen("data", "r");
            while(!feof(input_file)){
            ...........
            ..............
            }
            ......................

Please note that your program should be able to read input file with the name
as 'data'. If your program fails to do this, proper evaluation of your program
may not be possible and you may risk loosing many points.
Also note that you will have to send (email) only one file (include all the programs such as .h files, if you have any, in one file) preferably as an attachment.

The output of the program should look similar to the Gantt chart used in the book and for the homework assignments. Print the time slots in one line and in the following line underneath the time slots print the process number that uses the CPU in that time slot.

Time         :  0  1  2  3  4  5  6  .........
Process Id   : P0 P1 P1 P1 P2 P2 P3  .........
    

Compare the algorithms by estimating the waiting time, turnaround time, response time, and the number of context switches. Your program should output the results of the comparison of the two algorithms in a tabular form as given below:

			FIRST-COME, FIRST-SERVED (FCFS) ALGORITHUM
			P1	P2	P3	P4	P5
waiting time
turnaround time
response time
context switches
			ROUND-ROBIN (RR)  ALGORITHUM
			P1	P2	P3	P4	P5
waiting time
turnaround time
response time
context switches

Test your program with the numbers given in the CPU scheduling homework, and with several sets of numbers of you own choice. You need to submit your program by electronic mail to cis332fk@cis.njit.edu no later than Midnight on Monday, Oct 19, 1998. Please put "Homework 6" in the "Subject" line of the mail message.

Everybody has to submit their own implementation, no teamwork is allowed for the programming parts. We will check the submitted programs for similarities, and students submitting identical or very similar programs risk a lower grade.