OSTEP-MLFQ(多级反馈队列)-HOMEWORK(simulation)

1. Run a few randomly-generated problems with just two jobs and

two queues; compute the MLFQ execution trace for each. Make

your life easier by limiting the length of each job and turning off

I/Os.

运行一些随机产生的问题(?):两个job,两个队列,限制每个job的长度,不进行io,计算mlfq的运行轨迹

andy@LAPTOP-B6LCN2OM:~/HW-MLFQ$ ./mlfq.py -j 2 -n 2 -m 5 -M 0 -c
Here is the list of inputs:
OPTIONS jobs 2
OPTIONS queues 2
OPTIONS allotments for queue  1 is   1
OPTIONS quantum length for queue  1 is  10
OPTIONS allotments for queue  0 is   1
OPTIONS quantum length for queue  0 is  10
OPTIONS boost 0
OPTIONS ioTime 5
OPTIONS stayAfterIO False
OPTIONS iobump False


For each job, three defining characteristics are given:
  startTime : at what time does the job enter the system
  runTime   : the total CPU time needed by the job to finish
  ioFreq    : every ioFreq time units, the job issues an I/O
              (the I/O takes ioTime units to complete)

Job List:
  Job  0: startTime   0 - runTime   4 - ioFreq   0
  Job  1: startTime   0 - runTime   2 - ioFreq   0


Execution Trace:

[ time 0 ] JOB BEGINS by JOB 0
[ time 0 ] JOB BEGINS by JOB 1
[ time 0 ] Run JOB 0 at PRIORITY 1 [ TICKS 9 ALLOT 1 TIME 3 (of 4) ]
[ time 1 ] Run JOB 0 at PRIORITY 1 [ TICKS 8 ALLOT 1 TIME 2 (of 4) ]
[ time 2 ] Run JOB 0 at PRIORITY 1 [ TICKS 7 ALLOT 1 TIME 1 (of 4) ]
[ time 3 ] Run JOB 0 at PRIORITY 1 [ TICKS 6 ALLOT 1 TIME 0 (of 4) ]
[ time 4 ] FINISHED JOB 0
[ time 4 ] Run JOB 1 at PRIORITY 1 [ TICKS 9 ALLOT 1 TIME 1 (of 2) ]
[ time 5 ] Run JOB 1 at PRIORITY 1 [ TICKS 8 ALLOT 1 TIME 0 (of 2) ]
[ time 6 ] FINISHED JOB 1

Final statistics:
  Job  0: startTime   0 - response   0 - turnaround   4
  Job  1: startTime   0 - response   4 - turnaround   6

  Avg  1: startTime n/a - response 2.00 - turnaround 5.00

2. How would you run the scheduler to reproduce each of the examples in the chapter?

如何使用这个模拟器复现书中的一些例子?

简单起见,这里选择的是书中第一个例子:

如图:一个job,三级队列,0时进入,耗时200(为了答案比较简单,这里设置运行时间为10),不进行io

其中-a选项规定了每个队列的分配时间为1,-q选项规定了每个队列的时间片大小为1

andy@LAPTOP-B6LCN2OM:~/HW-MLFQ$ ./mlfq.py -l 0,10,0 -c -a 1 -q 1
Here is the list of inputs:
OPTIONS jobs 1
OPTIONS queues 3
OPTIONS allotments for queue  2 is   1
OPTIONS quantum length for queue  2 is   1
OPTIONS allotments for queue  1 is   1
OPTIONS quantum length for queue  1 is   1
OPTIONS allotments for queue  0 is   1
OPTIONS quantum length for queue  0 is   1
OPTIONS boost 0
OPTIONS ioTime 5
OPTIONS stayAfterIO False
OPTIONS iobump False


For each job, three defining characteristics are given:
  startTime : at what time does the job enter the system
  runTime   : the total CPU time needed by the job to finish
  ioFreq    : every ioFreq time units, the job issues an I/O
              (the I/O takes ioTime units to complete)

Job List:
  Job  0: startTime   0 - runTime  10 - ioFreq   0


Execution Trace:

[ time 0 ] JOB BEGINS by JOB 0
[ time 0 ] Run JOB 0 at PRIORITY 2 [ TICKS 0 ALLOT 1 TIME 9 (of 10) ]
[ time 1 ] Run JOB 0 at PRIORITY 1 [ TICKS 0 ALLOT 1 TIME 8 (of 10) ]
[ time 2 ] Run JOB 0 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 7 (of 10) ]
[ time 3 ] Run JOB 0 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 6 (of 10) ]
[ time 4 ] Run JOB 0 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 5 (of 10) ]
[ time 5 ] Run JOB 0 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 4 (of 10) ]
[ time 6 ] Run JOB 0 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 3 (of 10) ]
[ time 7 ] Run JOB 0 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 2 (of 10) ]
[ time 8 ] Run JOB 0 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 1 (of 10) ]
[ time 9 ] Run JOB 0 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 0 (of 10) ]
[ time 10 ] FINISHED JOB 0

Final statistics:
  Job  0: startTime   0 - response   0 - turnaround  10

  Avg  0: startTime n/a - response 0.00 - turnaround 10.00

3. How would you configure the scheduler parameters to behave just like a round-robin scheduler?

如何配置模拟器,让其表现得像rr(分时)?

例如:两个job,三个队列,同时进入,用时相同,不进行io,每个队列分配到时间和时间片都为1

andy@LAPTOP-B6LCN2OM:~/HW-MLFQ$ ./mlfq.py -l 0,5,0:0,5,0 -c -a 1 -q 1
Here is the list of inputs:
OPTIONS jobs 2
OPTIONS queues 3
OPTIONS allotments for queue  2 is   1
OPTIONS quantum length for queue  2 is   1
OPTIONS allotments for queue  1 is   1
OPTIONS quantum length for queue  1 is   1
OPTIONS allotments for queue  0 is   1
OPTIONS quantum length for queue  0 is   1
OPTIONS boost 0
OPTIONS ioTime 5
OPTIONS stayAfterIO False
OPTIONS iobump False


For each job, three defining characteristics are given:
  startTime : at what time does the job enter the system
  runTime   : the total CPU time needed by the job to finish
  ioFreq    : every ioFreq time units, the job issues an I/O
              (the I/O takes ioTime units to complete)

Job List:
  Job  0: startTime   0 - runTime   5 - ioFreq   0
  Job  1: startTime   0 - runTime   5 - ioFreq   0


Execution Trace:

[ time 0 ] JOB BEGINS by JOB 0
[ time 0 ] JOB BEGINS by JOB 1
[ time 0 ] Run JOB 0 at PRIORITY 2 [ TICKS 0 ALLOT 1 TIME 4 (of 5) ]
[ time 1 ] Run JOB 1 at PRIORITY 2 [ TICKS 0 ALLOT 1 TIME 4 (of 5) ]
[ time 2 ] Run JOB 0 at PRIORITY 1 [ TICKS 0 ALLOT 1 TIME 3 (of 5) ]
[ time 3 ] Run JOB 1 at PRIORITY 1 [ TICKS 0 ALLOT 1 TIME 3 (of 5) ]
[ time 4 ] Run JOB 0 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 2 (of 5) ]
[ time 5 ] Run JOB 1 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 2 (of 5) ]
[ time 6 ] Run JOB 0 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 1 (of 5) ]
[ time 7 ] Run JOB 1 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 1 (of 5) ]
[ time 8 ] Run JOB 0 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 0 (of 5) ]
[ time 9 ] FINISHED JOB 0
[ time 9 ] Run JOB 1 at PRIORITY 0 [ TICKS 0 ALLOT 1 TIME 0 (of 5) ]
[ time 10 ] FINISHED JOB 1

Final statistics:
  Job  0: startTime   0 - response   0 - turnaround   9
  Job  1: startTime   0 - response   1 - turnaround  10

  Avg  1: startTime n/a - response 0.50 - turnaround 9.50

4. Craft a workload with two jobs and scheduler parameters so that one job takes advantage of the older Rules 4a and 4b (turned on with the -S flag) to game the scheduler and obtain 99% of the CPU over a particular time interval.

制造一个workload:两个job,其中一个能够利用规则4a,4b(4a是如果用完了自己的时间片,优先级下降,4b是如果没有用完自己的时间片,优先级不变。打开-S选项,从而当发出io时不改变优先级)占用同时间段百分之九十九的cpu

分析:两个job,需要cpu的时间都是100,时间片大小为100,其中一个每99分钟发出一个io请求,另一个不发出

Here is the list of inputs:
OPTIONS jobs 2
OPTIONS queues 3
OPTIONS allotments for queue  2 is 100
OPTIONS quantum length for queue  2 is 100
OPTIONS allotments for queue  1 is 100
OPTIONS quantum length for queue  1 is 100
OPTIONS allotments for queue  0 is 100
OPTIONS quantum length for queue  0 is 100
OPTIONS boost 0
OPTIONS ioTime 1
OPTIONS stayAfterIO True
OPTIONS iobump True


For each job, three defining characteristics are given:
  startTime : at what time does the job enter the system
  runTime   : the total CPU time needed by the job to finish
  ioFreq    : every ioFreq time units, the job issues an I/O
              (the I/O takes ioTime units to complete)

Job List:
  Job  0: startTime   0 - runTime 100 - ioFreq  99
  Job  1: startTime   0 - runTime 100 - ioFreq   0


Execution Trace:

[ time 0 ] JOB BEGINS by JOB 0
[ time 0 ] JOB BEGINS by JOB 1
[ time 0 ] Run JOB 0 at PRIORITY 2 [ TICKS 99 ALLOT 100 TIME 99 (of 100) ]
[ time 1 ] Run JOB 0 at PRIORITY 2 [ TICKS 98 ALLOT 100 TIME 98 (of 100) ]
[ time 2 ] Run JOB 0 at PRIORITY 2 [ TICKS 97 ALLOT 100 TIME 97 (of 100) ]
[ time 3 ] Run JOB 0 at PRIORITY 2 [ TICKS 96 ALLOT 100 TIME 96 (of 100) ]
[ time 4 ] Run JOB 0 at PRIORITY 2 [ TICKS 95 ALLOT 100 TIME 95 (of 100) ]
[ time 5 ] Run JOB 0 at PRIORITY 2 [ TICKS 94 ALLOT 100 TIME 94 (of 100) ]
[ time 6 ] Run JOB 0 at PRIORITY 2 [ TICKS 93 ALLOT 100 TIME 93 (of 100) ]
[ time 7 ] Run JOB 0 at PRIORITY 2 [ TICKS 92 ALLOT 100 TIME 92 (of 100) ]
[ time 8 ] Run JOB 0 at PRIORITY 2 [ TICKS 91 ALLOT 100 TIME 91 (of 100) ]
[ time 9 ] Run JOB 0 at PRIORITY 2 [ TICKS 90 ALLOT 100 TIME 90 (of 100) ]
[ time 10 ] Run JOB 0 at PRIORITY 2 [ TICKS 89 ALLOT 100 TIME 89 (of 100) ]
[ time 11 ] Run JOB 0 at PRIORITY 2 [ TICKS 88 ALLOT 100 TIME 88 (of 100) ]
[ time 12 ] Run JOB 0 at PRIORITY 2 [ TICKS 87 ALLOT 100 TIME 87 (of 100) ]
[ time 13 ] Run JOB 0 at PRIORITY 2 [ TICKS 86 ALLOT 100 TIME 86 (of 100) ]
[ time 14 ] Run JOB 0 at PRIORITY 2 [ TICKS 85 ALLOT 100 TIME 85 (of 100) ]
[ time 15 ] Run JOB 0 at PRIORITY 2 [ TICKS 84 ALLOT 100 TIME 84 (of 100) ]
[ time 16 ] Run JOB 0 at PRIORITY 2 [ TICKS 83 ALLOT 100 TIME 83 (of 100) ]
[ time 17 ] Run JOB 0 at PRIORITY 2 [ TICKS 82 ALLOT 100 TIME 82 (of 100) ]
[ time 18 ] Run JOB 0 at PRIORITY 2 [ TICKS 81 ALLOT 100 TIME 81 (of 100) ]
[ time 19 ] Run JOB 0 at PRIORITY 2 [ TICKS 80 ALLOT 100 TIME 80 (of 100) ]
[ time 20 ] Run JOB 0 at PRIORITY 2 [ TICKS 79 ALLOT 100 TIME 79 (of 100) ]
[ time 21 ] Run JOB 0 at PRIORITY 2 [ TICKS 78 ALLOT 100 TIME 78 (of 100) ]
[ time 22 ] Run JOB 0 at PRIORITY 2 [ TICKS 77 ALLOT 100 TIME 77 (of 100) ]
[ time 23 ] Run JOB 0 at PRIORITY 2 [ TICKS 76 ALLOT 100 TIME 76 (of 100) ]
[ time 24 ] Run JOB 0 at PRIORITY 2 [ TICKS 75 ALLOT 100 TIME 75 (of 100) ]
[ time 25 ] Run JOB 0 at PRIORITY 2 [ TICKS 74 ALLOT 100 TIME 74 (of 100) ]
[ time 26 ] Run JOB 0 at PRIORITY 2 [ TICKS 73 ALLOT 100 TIME 73 (of 100) ]
[ time 27 ] Run JOB 0 at PRIORITY 2 [ TICKS 72 ALLOT 100 TIME 72 (of 100) ]
[ time 28 ] Run JOB 0 at PRIORITY 2 [ TICKS 71 ALLOT 100 TIME 71 (of 100) ]
[ time 29 ] Run JOB 0 at PRIORITY 2 [ TICKS 70 ALLOT 100 TIME 70 (of 100) ]
[ time 30 ] Run JOB 0 at PRIORITY 2 [ TICKS 69 ALLOT 100 TIME 69 (of 100) ]
[ time 31 ] Run JOB 0 at PRIORITY 2 [ TICKS 68 ALLOT 100 TIME 68 (of 100) ]
[ time 32 ] Run JOB 0 at PRIORITY 2 [ TICKS 67 ALLOT 100 TIME 67 (of 100) ]
[ time 33 ] Run JOB 0 at PRIORITY 2 [ TICKS 66 ALLOT 100 TIME 66 (of 100) ]
[ time 34 ] Run JOB 0 at PRIORITY 2 [ TICKS 65 ALLOT 100 TIME 65 (of 100) ]
[ time 35 ] Run JOB 0 at PRIORITY 2 [ TICKS 64 ALLOT 100 TIME 64 (of 100) ]
[ time 36 ] Run JOB 0 at PRIORITY 2 [ TICKS 63 ALLOT 100 TIME 63 (of 100) ]
[ time 37 ] Run JOB 0 at PRIORITY 2 [ TICKS 62 ALLOT 100 TIME 62 (of 100) ]
[ time 38 ] Run JOB 0 at PRIORITY 2 [ TICKS 61 ALLOT 100 TIME 61 (of 100) ]
[ time 39 ] Run JOB 0 at PRIORITY 2 [ TICKS 60 ALLOT 100 TIME 60 (of 100) ]
[ time 40 ] Run JOB 0 at PRIORITY 2 [ TICKS 59 ALLOT 100 TIME 59 (of 100) ]
[ time 41 ] Run JOB 0 at PRIORITY 2 [ TICKS 58 ALLOT 100 TIME 58 (of 100) ]
[ time 42 ] Run JOB 0 at PRIORITY 2 [ TICKS 57 ALLOT 100 TIME 57 (of 100) ]
[ time 43 ] Run JOB 0 at PRIORITY 2 [ TICKS 56 ALLOT 100 TIME 56 (of 100) ]
[ time 44 ] Run JOB 0 at PRIORITY 2 [ TICKS 55 ALLOT 100 TIME 55 (of 100) ]
[ time 45 ] Run JOB 0 at PRIORITY 2 [ TICKS 54 ALLOT 100 TIME 54 (of 100) ]
[ time 46 ] Run JOB 0 at PRIORITY 2 [ TICKS 53 ALLOT 100 TIME 53 (of 100) ]
[ time 47 ] Run JOB 0 at PRIORITY 2 [ TICKS 52 ALLOT 100 TIME 52 (of 100) ]
[ time 48 ] Run JOB 0 at PRIORITY 2 [ TICKS 51 ALLOT 100 TIME 51 (of 100) ]
[ time 49 ] Run JOB 0 at PRIORITY 2 [ TICKS 50 ALLOT 100 TIME 50 (of 100) ]
[ time 50 ] Run JOB 0 at PRIORITY 2 [ TICKS 49 ALLOT 100 TIME 49 (of 100) ]
[ time 51 ] Run JOB 0 at PRIORITY 2 [ TICKS 48 ALLOT 100 TIME 48 (of 100) ]
[ time 52 ] Run JOB 0 at PRIORITY 2 [ TICKS 47 ALLOT 100 TIME 47 (of 100) ]
[ time 53 ] Run JOB 0 at PRIORITY 2 [ TICKS 46 ALLOT 100 TIME 46 (of 100) ]
[ time 54 ] Run JOB 0 at PRIORITY 2 [ TICKS 45 ALLOT 100 TIME 45 (of 100) ]
[ time 55 ] Run JOB 0 at PRIORITY 2 [ TICKS 44 ALLOT 100 TIME 44 (of 100) ]
[ time 56 ] Run JOB 0 at PRIORITY 2 [ TICKS 43 ALLOT 100 TIME 43 (of 100) ]
[ time 57 ] Run JOB 0 at PRIORITY 2 [ TICKS 42 ALLOT 100 TIME 42 (of 100) ]
[ time 58 ] Run JOB 0 at PRIORITY 2 [ TICKS 41 ALLOT 100 TIME 41 (of 100) ]
[ time 59 ] Run JOB 0 at PRIORITY 2 [ TICKS 40 ALLOT 100 TIME 40 (of 100) ]
[ time 60 ] Run JOB 0 at PRIORITY 2 [ TICKS 39 ALLOT 100 TIME 39 (of 100) ]
[ time 61 ] Run JOB 0 at PRIORITY 2 [ TICKS 38 ALLOT 100 TIME 38 (of 100) ]
[ time 62 ] Run JOB 0 at PRIORITY 2 [ TICKS 37 ALLOT 100 TIME 37 (of 100) ]
[ time 63 ] Run JOB 0 at PRIORITY 2 [ TICKS 36 ALLOT 100 TIME 36 (of 100) ]
[ time 64 ] Run JOB 0 at PRIORITY 2 [ TICKS 35 ALLOT 100 TIME 35 (of 100) ]
[ time 65 ] Run JOB 0 at PRIORITY 2 [ TICKS 34 ALLOT 100 TIME 34 (of 100) ]
[ time 66 ] Run JOB 0 at PRIORITY 2 [ TICKS 33 ALLOT 100 TIME 33 (of 100) ]
[ time 67 ] Run JOB 0 at PRIORITY 2 [ TICKS 32 ALLOT 100 TIME 32 (of 100) ]
[ time 68 ] Run JOB 0 at PRIORITY 2 [ TICKS 31 ALLOT 100 TIME 31 (of 100) ]
[ time 69 ] Run JOB 0 at PRIORITY 2 [ TICKS 30 ALLOT 100 TIME 30 (of 100) ]
[ time 70 ] Run JOB 0 at PRIORITY 2 [ TICKS 29 ALLOT 100 TIME 29 (of 100) ]
[ time 71 ] Run JOB 0 at PRIORITY 2 [ TICKS 28 ALLOT 100 TIME 28 (of 100) ]
[ time 72 ] Run JOB 0 at PRIORITY 2 [ TICKS 27 ALLOT 100 TIME 27 (of 100) ]
[ time 73 ] Run JOB 0 at PRIORITY 2 [ TICKS 26 ALLOT 100 TIME 26 (of 100) ]
[ time 74 ] Run JOB 0 at PRIORITY 2 [ TICKS 25 ALLOT 100 TIME 25 (of 100) ]
[ time 75 ] Run JOB 0 at PRIORITY 2 [ TICKS 24 ALLOT 100 TIME 24 (of 100) ]
[ time 76 ] Run JOB 0 at PRIORITY 2 [ TICKS 23 ALLOT 100 TIME 23 (of 100) ]
[ time 77 ] Run JOB 0 at PRIORITY 2 [ TICKS 22 ALLOT 100 TIME 22 (of 100) ]
[ time 78 ] Run JOB 0 at PRIORITY 2 [ TICKS 21 ALLOT 100 TIME 21 (of 100) ]
[ time 79 ] Run JOB 0 at PRIORITY 2 [ TICKS 20 ALLOT 100 TIME 20 (of 100) ]
[ time 80 ] Run JOB 0 at PRIORITY 2 [ TICKS 19 ALLOT 100 TIME 19 (of 100) ]
[ time 81 ] Run JOB 0 at PRIORITY 2 [ TICKS 18 ALLOT 100 TIME 18 (of 100) ]
[ time 82 ] Run JOB 0 at PRIORITY 2 [ TICKS 17 ALLOT 100 TIME 17 (of 100) ]
[ time 83 ] Run JOB 0 at PRIORITY 2 [ TICKS 16 ALLOT 100 TIME 16 (of 100) ]
[ time 84 ] Run JOB 0 at PRIORITY 2 [ TICKS 15 ALLOT 100 TIME 15 (of 100) ]
[ time 85 ] Run JOB 0 at PRIORITY 2 [ TICKS 14 ALLOT 100 TIME 14 (of 100) ]
[ time 86 ] Run JOB 0 at PRIORITY 2 [ TICKS 13 ALLOT 100 TIME 13 (of 100) ]
[ time 87 ] Run JOB 0 at PRIORITY 2 [ TICKS 12 ALLOT 100 TIME 12 (of 100) ]
[ time 88 ] Run JOB 0 at PRIORITY 2 [ TICKS 11 ALLOT 100 TIME 11 (of 100) ]
[ time 89 ] Run JOB 0 at PRIORITY 2 [ TICKS 10 ALLOT 100 TIME 10 (of 100) ]
[ time 90 ] Run JOB 0 at PRIORITY 2 [ TICKS 9 ALLOT 100 TIME 9 (of 100) ]
[ time 91 ] Run JOB 0 at PRIORITY 2 [ TICKS 8 ALLOT 100 TIME 8 (of 100) ]
[ time 92 ] Run JOB 0 at PRIORITY 2 [ TICKS 7 ALLOT 100 TIME 7 (of 100) ]
[ time 93 ] Run JOB 0 at PRIORITY 2 [ TICKS 6 ALLOT 100 TIME 6 (of 100) ]
[ time 94 ] Run JOB 0 at PRIORITY 2 [ TICKS 5 ALLOT 100 TIME 5 (of 100) ]
[ time 95 ] Run JOB 0 at PRIORITY 2 [ TICKS 4 ALLOT 100 TIME 4 (of 100) ]
[ time 96 ] Run JOB 0 at PRIORITY 2 [ TICKS 3 ALLOT 100 TIME 3 (of 100) ]
[ time 97 ] Run JOB 0 at PRIORITY 2 [ TICKS 2 ALLOT 100 TIME 2 (of 100) ]
[ time 98 ] Run JOB 0 at PRIORITY 2 [ TICKS 1 ALLOT 100 TIME 1 (of 100) ]
[ time 99 ] IO_START by JOB 0
IO DONE
[ time 99 ] Run JOB 1 at PRIORITY 2 [ TICKS 99 ALLOT 100 TIME 99 (of 100) ]
[ time 100 ] IO_DONE by JOB 0
。。。。。
之后运行job1到结束

5. Given a system with a quantum length of 10 ms in its highest queue, how often would you have to boost jobs back to the highest priority level (with the -B flag) in order to guarantee that a single longrunning (and potentially-starving) job gets at least 5% of the CPU?

一个系统:最高优先级的队列的时间片为10ms,你需要多久提升一次job的优先级,从而保证一个长时间运行(可能遭遇饥饿现象)的job得到至少百分之五的cpu?

分析:要求“至少”,那么假设最高优先级队列里一直有job,也就是说只会执行最高优先级的job,那么只有当该job在最高优先级才会被执行

观察1000ms内的情况:运行10ms后,该job的优先级下降,要得到5%,那么需要每200ms提升一次优先级(将所有进程放到最高优先级队列)

6. One question that arises in scheduling is which end of a queue to add a job that just finished I/O; the -I flag changes this behavior for this scheduling simulator. Play around with some workloads and see if you can see the effect of this flag.

一个问题:刚完成io的job,应该放在队列的哪一端,-I可以让完成io后的job放在队列的最前端,使用模拟器,观察这个选项的作用

首先是加上-I的:

andy@LAPTOP-B6LCN2OM:~/HW-MLFQ$ ./mlfq.py -l 0,5,1:0,5,0 -c -q 5 -a 5 -I -i 1
Here is the list of inputs:
OPTIONS jobs 2
OPTIONS queues 3
OPTIONS allotments for queue  2 is   5
OPTIONS quantum length for queue  2 is   5
OPTIONS allotments for queue  1 is   5
OPTIONS quantum length for queue  1 is   5
OPTIONS allotments for queue  0 is   5
OPTIONS quantum length for queue  0 is   5
OPTIONS boost 0
OPTIONS ioTime 1
OPTIONS stayAfterIO False
OPTIONS iobump True


For each job, three defining characteristics are given:
  startTime : at what time does the job enter the system
  runTime   : the total CPU time needed by the job to finish
  ioFreq    : every ioFreq time units, the job issues an I/O
              (the I/O takes ioTime units to complete)

Job List:
  Job  0: startTime   0 - runTime   5 - ioFreq   1
  Job  1: startTime   0 - runTime   5 - ioFreq   0


Execution Trace:

[ time 0 ] JOB BEGINS by JOB 0
[ time 0 ] JOB BEGINS by JOB 1
[ time 0 ] Run JOB 0 at PRIORITY 2 [ TICKS 4 ALLOT 5 TIME 4 (of 5) ]
[ time 1 ] IO_START by JOB 0
IO DONE
[ time 1 ] Run JOB 1 at PRIORITY 2 [ TICKS 4 ALLOT 5 TIME 4 (of 5) ]
[ time 2 ] IO_DONE by JOB 0
[ time 2 ] Run JOB 0 at PRIORITY 2 [ TICKS 3 ALLOT 5 TIME 3 (of 5) ]
[ time 3 ] IO_START by JOB 0
IO DONE
[ time 3 ] Run JOB 1 at PRIORITY 2 [ TICKS 3 ALLOT 5 TIME 3 (of 5) ]
[ time 4 ] IO_DONE by JOB 0
[ time 4 ] Run JOB 0 at PRIORITY 2 [ TICKS 2 ALLOT 5 TIME 2 (of 5) ]
[ time 5 ] IO_START by JOB 0
IO DONE
[ time 5 ] Run JOB 1 at PRIORITY 2 [ TICKS 2 ALLOT 5 TIME 2 (of 5) ]
[ time 6 ] IO_DONE by JOB 0
[ time 6 ] Run JOB 0 at PRIORITY 2 [ TICKS 1 ALLOT 5 TIME 1 (of 5) ]
[ time 7 ] IO_START by JOB 0
IO DONE
[ time 7 ] Run JOB 1 at PRIORITY 2 [ TICKS 1 ALLOT 5 TIME 1 (of 5) ]
[ time 8 ] IO_DONE by JOB 0
[ time 8 ] Run JOB 0 at PRIORITY 2 [ TICKS 0 ALLOT 5 TIME 0 (of 5) ]
[ time 9 ] FINISHED JOB 0
[ time 9 ] Run JOB 1 at PRIORITY 2 [ TICKS 0 ALLOT 5 TIME 0 (of 5) ]
[ time 10 ] FINISHED JOB 1

Final statistics:
  Job  0: startTime   0 - response   0 - turnaround   9
  Job  1: startTime   0 - response   1 - turnaround  10

  Avg  1: startTime n/a - response 0.50 - turnaround 9.50

然后是不加上-I:

andy@LAPTOP-B6LCN2OM:~/HW-MLFQ$ ./mlfq.py -l 0,5,1:0,5,0 -c -q 5 -a 5  -i 1
Here is the list of inputs:
OPTIONS jobs 2
OPTIONS queues 3
OPTIONS allotments for queue  2 is   5
OPTIONS quantum length for queue  2 is   5
OPTIONS allotments for queue  1 is   5
OPTIONS quantum length for queue  1 is   5
OPTIONS allotments for queue  0 is   5
OPTIONS quantum length for queue  0 is   5
OPTIONS boost 0
OPTIONS ioTime 1
OPTIONS stayAfterIO False
OPTIONS iobump False


For each job, three defining characteristics are given:
  startTime : at what time does the job enter the system
  runTime   : the total CPU time needed by the job to finish
  ioFreq    : every ioFreq time units, the job issues an I/O
              (the I/O takes ioTime units to complete)

Job List:
  Job  0: startTime   0 - runTime   5 - ioFreq   1
  Job  1: startTime   0 - runTime   5 - ioFreq   0


Execution Trace:

[ time 0 ] JOB BEGINS by JOB 0
[ time 0 ] JOB BEGINS by JOB 1
[ time 0 ] Run JOB 0 at PRIORITY 2 [ TICKS 4 ALLOT 5 TIME 4 (of 5) ]
[ time 1 ] IO_START by JOB 0
IO DONE
[ time 1 ] Run JOB 1 at PRIORITY 2 [ TICKS 4 ALLOT 5 TIME 4 (of 5) ]
[ time 2 ] IO_DONE by JOB 0
[ time 2 ] Run JOB 1 at PRIORITY 2 [ TICKS 3 ALLOT 5 TIME 3 (of 5) ]
[ time 3 ] Run JOB 1 at PRIORITY 2 [ TICKS 2 ALLOT 5 TIME 2 (of 5) ]
[ time 4 ] Run JOB 1 at PRIORITY 2 [ TICKS 1 ALLOT 5 TIME 1 (of 5) ]
[ time 5 ] Run JOB 1 at PRIORITY 2 [ TICKS 0 ALLOT 5 TIME 0 (of 5) ]
[ time 6 ] FINISHED JOB 1
[ time 6 ] Run JOB 0 at PRIORITY 2 [ TICKS 3 ALLOT 5 TIME 3 (of 5) ]
[ time 7 ] IO_START by JOB 0
IO DONE
[ time 7 ] IDLE
[ time 8 ] IO_DONE by JOB 0
[ time 8 ] Run JOB 0 at PRIORITY 2 [ TICKS 2 ALLOT 5 TIME 2 (of 5) ]
[ time 9 ] IO_START by JOB 0
IO DONE
[ time 9 ] IDLE
[ time 10 ] IO_DONE by JOB 0
[ time 10 ] Run JOB 0 at PRIORITY 2 [ TICKS 1 ALLOT 5 TIME 1 (of 5) ]
[ time 11 ] IO_START by JOB 0
IO DONE
[ time 11 ] IDLE
[ time 12 ] IO_DONE by JOB 0
[ time 12 ] Run JOB 0 at PRIORITY 2 [ TICKS 0 ALLOT 5 TIME 0 (of 5) ]
[ time 13 ] FINISHED JOB 0

Final statistics:
  Job  0: startTime   0 - response   0 - turnaround  13
  Job  1: startTime   0 - response   1 - turnaround   6

  Avg  1: startTime n/a - response 0.50 - turnaround 9.50

猜你喜欢

转载自blog.csdn.net/RedemptionC/article/details/105953329
今日推荐