Homework:
This program, scheduler.py, allows you to see how different schedulers perform under scheduling metrics such as response time, turnaround time, and total wait time. See the README for details.
Questions:
1. Compute the response time and turnaround time when running three jobs of length 200 with the SJF and FIFO schedulers.
python scheduler.py -p FIFO -j 3 -s 100 -c
python scheduler.py -p SJF -l 200,200,200 -c
2. Now do the same but with jobs of different lengths: 100, 200, and 300.
python scheduler.py -p FIFO -l 100,200,300 -c
python scheduler.py -p SJF -l 100,200,300 -c
3. Now do the same, but also with the RR scheduler and a time-slice of 1.
python scheduler.py -p RR -l 100,200,300 -c
4. For what types of workloads does SJF deliver the same turnaround times as FIFO?
长度短的工作先到,长度长的工作后到。
(如:工作负载分别为100,200,300)
5. For what types of workloads and quantum lengths does SJF deliver the same response times as RR?
工作负载的长度都特别短,最长不超过时间片的长度。
保证在第二个时间片来临时,只有最后一个工作负载没有完成。
(如:时间片为10,工作负载分别为:1,2,3,5)
6. What happens to response time with SJF as job lengths increase? Can you use the simulator to demonstrate the trend?
响应时间随着工作负载长度的增加而增加。但是RR就不会,即无论工作时长是多少,响应时间都不变
模拟程序如下:
python3 scheduler.py -p SJF -l 1,2,3 -c
python3 scheduler.py -p SJF -l 10,20,30 -c
python3 scheduler.py -p SJF -l 100,200,300 -c
7. What happens to response time with RR as quantum lengths in worst crease? Can you write an equation that gives the worst-case response time, given N jobs?
RR的响应时间随着时间片长度的增加而增加。
设时间片长度为m
响应时间=(0+1+2+...+(n-1))* m / N
=m* (N+1) / 2