admin管理员组

文章数量:1530517

操作系统第四次作业

问题一:Why is it important for the scheduler to distinguish I/O-bound programs from CPU-bound programs?
答:

I/O密集型程序通常具有大量的短CPU执行,而CPU密集型程序可能只有少量长CPU执行,而短CPU执行执行的频率很高。所以需要识别两种类型的程序,进而采取合适的调度算法,从而使得计算机更加高效。

问题二:

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

ProcessBurst TimePriority
P1103
P211
P323
P414
P552

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 smaller priority number implies a higher priority), and RR (quantum = 1).

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 the scheduling algorithms in part a?

d. Which of the algorithms in part a results in the minimum average waiting time (over all processes)?

答:


问题三:

Which of the following scheduling algorithms could result in starvation?

a. First-come, first-served

b. Shortest job first

c. Round robin

d. Priority

答:

b、d

问题四:

The traditional UNIX scheduler enforces an inverse relationship between priority numbers and priorities: The higher the number, the lower the priority. The scheduler recalculates process priorities once per second using the following function:

Priority = (Recent CPU usage / 2) + Base

where base = 60 and recent CPU usage refers to a value indicating how often a process has used the CPU since priorities were last recalculated. Assume that recent CPU usage for process P1 is 40, process P2 is 18, and process P3 is 10. What will be the new priorities for these three processes when priorities are recalculated? Based on this information, does the traditional UNIX scheduler raise or lower the relative priority of a CPU-bound process?

答:

问题一:

P1 = 40/2 + 60 = 80

P2 = 18/2 + 60 = 69

P3 = 10/2 + 60 = 65

故优先级从高到低为P3、P2、P1

问题二:

传统的UNIX调度程序是降低了CPU密集型进程的相对优先级

因为CPU密集型进程相较于I/O密集型进程占用更多的CPU时间

故最后CPU密集型进程的Priority值会比I/O密集型进程的Priority值增长地更快,优先级也降低得更快,所以相对而言,降低了了CPU密集型进程的优先级

本文标签: 作业第四次操作系统