操作系统第二次作ä¸?/p>
第五ç«?/p>
5.1 Why is it important for the scheduler to distinguish I/O-bound programs from
CPU-bound programs?
为何调度器要区分
IO
约束程序å’?/p>
CPU
约束程序ï¼?/p>
答:二者对
CPU
的使用有较大差别ï¼?/p>
IO
操作只需少量çš?/p>
CPU
时间片,大部分时
间用äº?/p>
IO
的等待,è€?/p>
CPU
约束操作需要用整块时间,在
CPU
操作的后台可以同
时运è¡?/p>
IO
等待操作,二者互不影响,通过区分两种操作,加上系统的调度,可
以更好的利用
CPU
资源,提高运行效çŽ?/p>
5.3 Consider the exponential average formula used to predict the length of the next
CPU
burst.
What
are
the
implications
of
assigning
the
following
values
to
the
parameters used by the algorithm?
a. = 0 and 0 = 100milliseconds
b. = 0.99 and 0 = 10milliseconds
考虑预测下一ä¸?/p>
CPU
区间的指数平均公式,当下列参数分别取对应值时的影å“?/p>
是什ä¹?/p>
答:指数平均公式ï¼?/p>
T(n+1)=at(n)+(1-a)Tn
参数
Tn+1
的含义是预测下一
CPU
区间的预测值,
tn
为第
n
�/p>
CPU
区间的长
度,
a
代表预测值和上一区间长度的【相关度ã€?/p>
,也就是说,
a
取值越大,上一ä¸?/p>
区间(真实发生的)长度对预测值的影响就越大,反之ï¼?/p>
a
取值越小,预测值就
主要体现为上一次的预测值ã€?/p>
a=0
ï¼?/p>
t=100ms
a=0
代表真实发生的区间长度不会影响预测,也就是说预测值会一直保持为
上一次预测值,å�?/p>
t
,故本次预测值为
100ms
a=0.99 t=10ms
a=0.99
代表预测值基本完全体现为上一次真实发生的
CPU
区间长度ï¼?/p>
也就æ˜?/p>
说预测值基本是前一个区间的长度,比å¦?/p>
tn=50ms
,则下一次预测值也大致ä¸?/p>
50ms
�/p>
5.4 Consider the following set of processes, with the length of the CPU-burst time
given in milliseconds:
Process Burst Time Priority
P1
10
3
P2
1
1
P3
2
3
P4
1
4
P5
5
2
The processes are assumed to have arrived in the order P1 , P2 ,P3 , P4 , P5 , all at
time 0.
a. Draw four Gantt charts illustrating the execution of these processes using FCFS,
SJF, a nonpreemptive priority (a smaller priority number implies a higher priority),