首页 > 其他分享 >操作系统导论习题解答(8. Multi-level Feedback)

操作系统导论习题解答(8. Multi-level Feedback)

时间:2022-10-14 19:14:53浏览次数:85  
标签:Multi jobs level job running scheduler time 习题 CPU

0. 文件地址

Homework

1. MLFQ: Basic Rules

在这里插入图片描述
在这里插入图片描述

2. Attempt #1: How To Change Priority

在这里插入图片描述

2.1 Example 1: A Single Long-Running Job

在这里插入图片描述

2.2 Example 2: Along Came A Short Job

In this example, there are two jobs: A, which is a long-running CPU-intensive job, and B, which is a short-running interactive job. Assume A has been running for some time, and then B arrives. What will happen? Will MLFQ approximate SJF for B?
在这里插入图片描述
A (shown in black) is running along in the lowest-priority queue (as would any long-running CPU intensive jobs); B (shown in gray) arrives at time T = 100, and thus is inserted into the highest queue; as its run-time is short (only 20 ms), B completes before reaching the bottom queue, in two time slices; then A resumes running (at low priority).

2.3 Example 3: What About I/O?

在这里插入图片描述
在这里插入图片描述

2.4 Problems With Our Current MLFQ

  1. starvation: if there are “too many” interactive jobs in the system, they will combine to consume all CPU time, and thus long-running jobs will never receive any CPU time (they starve).
  2. game the scheduler: Gaming the scheduler generally refers to the idea of doing something sneaky to trick the scheduler into giving you more than your fair share of the resource.
  3. a program may change its behavior over time: what was CPU-bound may transition to a phase of interactivity.

3. Attempt #2: The Priority Boost

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

4. Attempt #3: Better Accounting

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

5. Tuning MLFQ And Other Issues

在这里插入图片描述
在这里插入图片描述

6. Summary

在这里插入图片描述

7. Homework (Simulation)

在这里插入图片描述

Question & Answer

在这里插入图片描述

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.

在这里插入图片描述
在这里插入图片描述

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

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

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

in order to reflect RR scheduling, this parameter should have the following points:
1. Multiple jobs
2. One queue
3. There are the time slice

// x >= 2,y > 0
python mlfq.py -n 1 -j x -q y

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.

to be continue....

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 long running (and potentially-starving) job gets at least 5% of the CPU?

T(boost) <= T(time slice) / 0.05 = 10ms / 0.05 = 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.

to be continue....

标签:Multi,jobs,level,job,running,scheduler,time,习题,CPU
From: https://www.cnblogs.com/astralcon/p/16792686.html

相关文章