操作系统面试题,求答案

时间:2022-10-03 19:07:26
1.Many CPU scheduling algorithms are parameterized. For example ,the RR algorithm requires 
a parameter to indicate the time slice. Multilevel feedback queues require parameters to define the  
number of queues , the scheduling algorithms for each queue , the criteria used to move processes  
between queues, and so on. 
These algorithms are thus really sets of algorithms (for example, the set of RR algorithms for all time slices, and so on). One set of algorithms may include another (for example , the FCFS(first come first serve) algorithm is the RR algorithm with an infinite time quantum). What (if any) relation holds between the following pairs of sets of algorithms? 
     a. Priority and SJF 
     b. Multilevel feedback queues and FCFS 
     c. Priority and FCFS 
     d. RR and SJF 

2.  A bank teller provides service to customers who arrive in a Poisson pattern at an average 
rate of 20 per hour. Service times are distributed exponentially with an average time of two 
minutes. 
a) What is the mean waiting time for each customer? 
b) A second teller arrives back from lunch and begins serving customers. A single line 
continues to serve both tellers. What is the mean waiting time when both tellers are working? 
HINT: Refer to Allen's paper. Erlang's C formula for 2 servers can be given as 
C(2,U) = U / (2 + 2U - U2) 

A page-replacement algorithm should minimize the number of page faults. We can achieve this minimization by distributing heavily used pages evenly over all of memory, rather than having them compete for a small number of page frames. We can associate with each page frame a counter of the number of pages associated with that frame. Then , to replace a page ,we can search  
for the page frame with the smallest counter. 
a. Define a page-replacement algorithm using this basic idea. Specifically address these problems: 
1. What the initial value of the counters is  
2. When counters are increased 
3. When counters are decreased 
4. How the page to be replaced is selected 
b. How many page faults occur for your algorithm for the following reference string, with four page frames? 
        1,2,3,4,5,3,4,1,6,7,8,7,8,9,7,8,9,5,4,5,4,2. 
c.  What is the minimum number of page faults for an optimal page-replacement strategy for the reference string in part b with four page frames? 
一个页面置换算法应使发生页错误的次数最小化。怎样才能通过将使用频率高的页平均分配到整个内存而不只是竞争使用少数几个页帧页来达到这种最小化。可以对每个页帧设置一个计数器来记录与此帧相关的页数。那么当置换一个页时,就可以查找计数器值最小的页帧。 
a. 基于这种基本思想,定义一个页面置换算法。特别注意的问题: 
1. 计数器初始值是多少? 
2. 什么时候计数器值增加? 
3. 什么时候计数器值减小? 
4. 怎样选择要被置换的页? 
b. 设有4个页帧,对于下面引用序列,你的算法会发生多少次页错误。 
       1,2,3,4,5,3,4,1,6,7,8,7,8,9,7,8,9,5,4,5,4,2. 
c. 最佳页面置换算法对于4页帧的题b中的引用序列的最小页错误数为多少? 

4 个解决方案

#1


支持一下

#2


难!太难了!

#3


关注。

#4


关注 接分

#1


支持一下

#2


难!太难了!

#3


关注。

#4


关注 接分