April 7th, 2013, 01:06 AM
[Homework] Scheduling Algorithm problem
I have a simple exercise that I'm having a bit of trouble getting started with.
I have figured that in order to read the txt file, I should be using a buffered reader and to calculate things like averages I just need to read the integers from the txt file and put them into a formula.
Could someone help point me in the right direction, or help me with a bit of pseudocode? Any help would be hugely appreciated.
Write a Java program that will simulate First Come First Serve, Shortest Remaining Time, and Round
Robin scheduling algorithms. For each algorithm, the program should compute the turnaround time
and the waiting time of every job as well as the average turnaround time and average waiting time.
The process information will be read from an input file. The format is as follows:
All fields are integers where:
Process_id is a unique numeric process ID
Arrival_time is the time when the process arrives in milliseconds
CPU_time is the amount of estimated CPU time requested by the process
All the fields will be delimited by a comma.
An example of a sample input file is as follows:
The program will accept command line arguments. The program usage will be as follows:
./Question1 input_file [FCFS|SRT|RR] [time_quantum]where, Question1 is name of the java program and input_file is the input file containing the process information.
FCFS refers to the First Come First Serve policy and is non-pre-emptive. SRT refers to Shortest Remaining Time and is pre-emptive.
RR refers to Round Robin, which is pre-emptive and the time quantum only applies to this algorithm. Ignore context switching time. Note the last argument is only needed in case of Round Robin.
Suppose you want to run the SRT algorithm on a process list contained in input file called process.txt, then you would run your program as follows:
./Question1 process.txt SRT
If you want to run the RR algorithm on the same input file with a time quantum of 5 milliseconds, then you would run your program as follows:
./Question1 process.txt RR 5
Turnaround time = completion time – arrival time
Waiting time = Turnaround time – CPU time taken by the process
Last edited by libertad; April 7th, 2013 at 02:37 AM.
Reason: Incomplete title