Homework
This program, lottery.py, allows you to see how a lottery scheduler works. See the README for details.
questions:
1. Compute the solutions for simulations with 3 jobs and random seeds of 1, 2, and 3.
python lottery.py -j 3 -s 1 -c
python lottery.py -j 3 -s 2 -c
python lottery.py -j 3 -s 3 -c
2. Now run with two specific jobs: each of length 10, but one (job 0) with just 1 ticket and the other (job 1) with 100 (e.g., -l 10:1,10:100). What happens when the number of tickets is so imbalanced? Will job 0 ever run before job 1 completes? How often? In general, what does such a ticket imbalance do to the behavior of lottery scheduling?
job1完成之前,job0基本上是没有机会运行的
这种彩票不平衡会使这两个job像在队列中一样,前面的job不运行完,后面的job基本就没机会运行
python lottery.py -j 2 -l 10:1,10:100 -c
3. When running with two jobs of length 100 and equal ticket allocations of 100 (-l 100:100,100:100), how unfair is the scheduler? Run with some different random seeds to determine the (probabilistic) answer; let unfairness be determined by how much earlier one job finishes than the other.
seed = 1
U = 196 / 200 = 0.98
python lottery.py -j 2 -l 100:100,100:100 -s 1 -c
seed = 2
U = 190 / 200 = 0.95
python lottery.py -j 2 -l 100:100,100:100 -s 2 -c
seed = 3
U = 196 / 200 = 0.98
python lottery.py -j 2 -l 100:100,100:100 -s 3 -c
seed = 4
U = 199 / 200 = 0.995
python lottery.py -j 2 -l 100:100,100:100 -s 4 -c
4. How does your answer to the previous question change as the quantum size (-q) gets larger?
q = 5
U = 190 / 200 = 0.95
python lottery.py -j 2 -l 100:100,100:100 -s 1 -q 5 -c
q = 10
U = 160 / 200 = 0.8
python lottery.py -j 2 -l 100:100,100:100 -s 1 -q 10 -c
q = 50
U = 150 / 200 = 0.75
python lottery.py -j 2 -l 100:100,100:100 -s 1 -q 50 -c
随着时间片长度的增加,抽取彩票的次数将减少,每次中奖的进程运行的时间将增加
因此会越来越不公平