Question
First, run without the -c flag: this shows you what problem to solve without revealing the answers. For example, if you want to compute response,
First, run without the -c flag: this shows you what problem to solve without revealing the answers. For example, if you want to compute response, turnaround, and wait for three jobs using the FIFO policy, run this:
python scheduler.py -p FIFO -j 3 -s 100
This specifies the FIFO policy with three jobs, and, importantly, a specific random seed of 100. If you want to see the solution for this exact problem, you have to specify this exact same random seed again. Let's run it and see
what happens. This is what you should see:
python scheduler.py -p FIFO -j 3 -s 100
ARG policy FIFO
ARG jobs 3
ARG maxlen 10
ARG seed 100
Here is the job list, with the run time of each job:
Job 0 (length = 2)
Job 1 (length = 5)
Job 2 (length = 8)
Compute the turnaround time, response time, and wait time for each job. When you are done, run this program again, with the same arguments, but with -c, which will thus provide you with the answers. You can use -s
As you can see from this example, three jobs are generated: job 0 of length 2, job 1 of length 5, and job 2 of length 8. As the program states, you can now use this to compute some statistics and see if you have a grip on the basic
concepts.
Once you are done, you can use the same program to "solve" the problem and see if you did your work correctly. To do so, use the "-c" flag. The output:
python scheduler.py -p FIFO -j 3 -s 100 -c
ARG policy FIFO
ARG jobs 3
ARG max len 10
ARG seed 100
Here is the job list, with the run time of each job:
Job 0 (length = 2)
Job 1 (length = 5)
Job 2 (length = 8)
Check the solution against your calculations.
Execution trace:
[time 0] Run job 0 for 2.00 secs (DONE at 2.00)
[time 1] Run job 1 for 5.00 secs (DONE at 7.00)
[time 5] Run job 2 for 8.00 secs (DONE at 15.00)
Final statistics:
Job 0 -- Response: 0.00 Turnaround 2.00 Wait 0.00
Job 1 -- Response: 1.00 Turnaround 7.00 Wait 2.00
Job 2 -- Response: 5.00 Turnaround 15.00 Wait 7.00
Average -- Response: 3.00 Turnaround 8.00 Wait 3.00
As you can see from the figure, the -c flag shows you what happened. Job 0 ran first for 2 second, Job 1 ran second for 5, and then Job 2 ran for 8 seconds. Not too hard; it is FIFO, after all! The execution trace shows these results.
The final statistics are useful too: they compute the "response time" (the time a job spends waiting after arrival before first running), the "turnaround time" (the time it took to complete the job since first arrival), and the total "wait time" (any time spent ready but not running). The stats are shown per job and then as an average across all jobs. Of course, you should have computed these things all before running with the "-c" flag!
If you want to try the same type of problem but with different inputs, try changing the number of jobs or the random seed or both. Different random seeds basically give you a way to generate an infinite number of different problems for yourself, and the "-c" flag lets you check your own work. Keep doing this until you feel like you really understand the concepts.
One other useful flag is "-l" (that's a lower-case L), which lets you specify the exact jobs you wish to see scheduled. For example, if you want to find out how SJF would perform with three jobs of lengths 5, 10, and 15, you can run:
python scheduler.py -p SJF -l 5,10,15
ARG policy SJF
ARG list 5,10,15
Here is the job list, with the run time of each job:
Job 0 (length = 5.0)
Job 1 (length = 10.0)
Job 2 (length = 15.0)
And then you can use -c to solve it again. Note that when you specify the exact jobs, there is no need to specify a random seed or the number of jobs: the jobs lengths are taken from your comma-separated list.
To run with Round Robin scheduling, we’ll also need to indicate the quantum, the size of the time slice that each job will be allotted for each turn at the CPU. We use RR with the -p option, and a numeric value with the -q option for the quantum. For example, here we run 3 processes with lengths, 5, 10 and 15 using Round Robin scheduling with a time quantum of 4.
python scheduler.py -p RR -q 4 -l 5,10,15
To get a complete list of flags and options, run this command:
python scheduler.py -h
Use the scheduling simulation for these questions.
1. Compute the response time and turnaround time when running three jobs of length 200 with the SJF and FIFO schedulers.
2. Now do the same but with jobs of different lengths: 100, 200, and 300.
3. Now do the same, but also with the RR scheduler and a time-slice of 1.
4. For what types of workloads (job lengths) does SJF deliver the same turnaround times as FIFO?
5. For what types of workloads and quantum lengths does SJF deliver the same response times as RR?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started