《Operating Systems: Three Easy Pieces》第九章习题解答

Homework (Simulation)

This program, lottery.py, allows you to see how a lottery scheduler
works. See the README for details.
用的学校机房的电脑~

Question & Answer

《Operating Systems: Three Easy Pieces》第九章习题解答

1. Compute the solutions for simulations with 3 jobs and random seeds of 1, 2, and 3.

《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答

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?

《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答

《Operating Systems: Three Easy Pieces》第九章习题解答

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.

《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
我觉得不管seed为多少,两个job完成时间都不会差距很大。但是我也只测验了一部分,样本太小,希望大家能自己多测验…

4. How does your answer to the previous question change as the quantum size (-q) gets larger?

《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
《Operating Systems: Three Easy Pieces》第九章习题解答
可以看出来 the length of time slice (- q)对job完成时间的影响非常大。

5. Can you make a version of the graph that is found in the chapter? What else would be worth exploring? How would the graph look with a stride scheduler?

to be continue…