admin管理员组

文章数量:1531792

目录

一、例题

二、调度准则

三、调度算法(Scheduling algorithm)

附:线程调度


一、例题

1.Explain the difference between preemptive and nonpreemptive scheduling.

Answer:

如果调度方案是非抢占的(nonpreemptive),一旦CPU分配给一个进程,那么该进程会一直使用CPU直到进程终止或切换到等待状态。而抢占的调度方案会在进程未达到终止或等待状态就切换进程(比如出现中断或 等待状态的进程的I/O完成而切换到就绪状态)。

简而言之就是CPU是否允许当前进程未结束或到达等待状态就进行进程切换。

 

2.Discuss how the following pairs of scheduling criteria conflict in certain settings.

a. CPU utilization and response time (CPU利用率和响应时间)

CPU利用率一定程度上取决于进程上下文切换的频繁程度,比如我们采用FCFS的调度方案那么CPU利用率也许会比较大但是不可避免的是响应时间会增加(显然这种方式进程等待时间会很不理想)。

 

b. Average turnaround time and maximum waiting time (平均周转时间和最大等待时间)

为使平均周转时间少,需要优先处理所需时间少的任务,然后这样时间长度长的进程的等待时间无疑会被加长。

 

c. I/O device utilization and CPU utilization(I/O设备利用率和CPU利用率)

CPU利用率的提高需要减少上下文切换的次数,而I/O设备利用率的提高需要让I/O设备一准备就绪就能马上运行—这需要上下文切换来实现,所以两者是矛盾的。

 

3.Consider the following set of processes,with the length of the CPU burst given in milliseconds:

The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.

a. Draw four Gantt charts that illustrate the execution of these processes using the following scheduling algorithms: FCFS, SJF, nonpreemptive priority(a larger priority number implies a higher priority), and RR (quantum = 2).

b. What is the turnaround time of each process for each of the scheduling algorithms in part a?

c. What is the waiting time of each process for each of these scheduling algorithms?

本文标签: 学习笔记操作系统CPU