In this lab you will simulate scheduling in order to see how the time required depends on the scheduling algorithm and the request patterns. The idea is to schedule the CPU for several simulated processes that alternately compute and request I/O. For each process, let A be the arrival time and C is the total CPU time needed. We will make the simplifying assumption that, for each process, the CPU burst times are uniformly distributed random integers (UDRIs) in the interval (0,B], i.e. 0 < t <= B. If the t chosen is larger that the total CPU time remaining, reduce t to the remianing time. Similarly, we assume the I/O times are UDRIs in the interval [1,IO]. (the [a,b] notation is inclusive, meaning that a and b are included in the range.
So a process is characterized by just four numbers A, B, C, and IO. Please do not confuse IO with the number 10. A, B, C, and IO are expressed in ``time units'' (you may think of them as centiseconds, i.e. hundredth of a second, if you prefer).
You are to read a file describing n processes (i.e. n quadruples of numbers) and then simulate the n processes until they all terminate. The way to do this is to keep track of the state of each process and advance time making any state transitions needed.
Recall that in a real operating system, the scheduler only executes whenever an interrupt or trap occurs. Similarly, your simulation should be event based. This means that it should only simulate execution of the scheduler each time a program or os event occurs and not just enumerate all each clock times.. Only partial credit will be given to time-based simulations that evaluate at each time step even if they compute the correct results.
Each event should be emitted along with relevant process states. For example:
... At time = 16 - process 2 io started (blocked until 18) (remaining = 3, burst = 2), - process 3 running (remaining = 12, burst = 10) At time = 18 - process 2 i/o completed (now ready) (remaining=3, burst=2) - process 3 preempted (remaining = 10, burst = 8) - process 2 running (remaining = 3, burst = 2) ...At the end of the run you should first print an identification of the run including the scheduling algorithm used, any parameters (e.g. the quantum for RR), and the number of processes simulated. You should then print for each process
Then print the following summary data.
You should have separate runs using each of the following scheduling algorithms.
For each scheduling algorithm there are several runs with different process mixes. A mix is a value of n followed by n (A, B, C, IO) quadruples. Below are a few to start with, I may post/distribute others.
In order to facilitate your detection of errors and Xing's job of grading, please follow the following guidelines that I hope will facilitate your generation of reproducible results.
I strongly encourage students to assist each other debug by distributing test data & execution traces that you believe are correct. However, sharing of source-code is prohibited.