OS测试题

来源:互联网 发布:软件fmea可靠性分析 编辑:程序博客网 时间:2024/05/23 15:06

1.Measurements(测量) of a certain system have shown that the average process runs for a time of T=10ms before blocking(阻塞) on I/O. A process switch(切换) requires a time of S=5ms which is effectively wasted(完全浪费). For round-robin scheduling(轮转调度) with quantum(时间片)Q ms.(2 points)
a.If Q=5ms, the CPU efficiency(CPU使用率)is_____________________
b.If Q=15ms, the CPU efficiency is_____________________
2.For the process listed in the following table, please write out the processes’ average turnaround time(平均周转时间) for the following algorithms(算法).1. Shortest job/process first; 2.Shortest remaining time next; 3. Round robin(quantum=3s); 4.Priority scheduling(Non-preemptive,with 4 being the highest priority).You must write out the computing course(计算过程).

Process Arrival time Processing time(s) Priority A 0 4 2 B 1 8 1 C 2 5 4 D 4 3 3

3.A system has four process and three assignable resources(可分配资源). The current allocation(当前分配) and maximum(最大) needs are follows:

Process Allocated Maximum Available Process A 2 0 1 2 2 1 0 x 0 Process B 1 1 0 5 2 2 Process C 1 0 0 4 0 2 Process D 1 0 2 2 1 2

(1)What is the smallest value of x for which this is a safe state? X=__;
(2)If x is the smallest value, please fill in the following blanks:
Process________can be satisfied(资源满足)first, when it is over(运行完),the available is _
Process________can be satisfied next, when it is over, the available is _
Process________can be satisfied next, when it is over, the available is _
Process________can be satisfied next, when it is over, the available is _
4.The computer room(计算机室)has 2m computers. There are 2n students to attend the computer class(参加计算机课). They must abide(遵守):
1)There is only one entrance(入口)for the room. They come inside and go out by it,And it only can be used by one student every time
2)One computer can only be used by one student, the teacher do not use the computer
3)When the student do over his experiment(计算机实验),he (she) can leave the room
Please describe the course for the using computer room(请描述使用机房的过程) with Down(P) and Up(V) operating

答案解析

1.某一系统的测量表明在I/O上的阻塞之前平均进程运行时间为T=10ms。一个进程切换需要完全浪费S=5ms,对于时间片为Qms的轮转调度
如果Q=5ms,CPU使用率为____50%____
如果Q=15ms,CPU使用率为___66.67%____
这道题是有公式的,公式如下:

Q CPU efficiency Q=∞ T/ (T+S) Q>T T/ (T+S) Q=S 50% Q nearly 0 nearly 0

2.因为A是最先到的,所以A总是第一个运行的。
1.最短作业优先
A.4-0=4
B.20-1=19
C.12-2=20
D.7-4=3
Average:(4+19+20+3)/4 = 11.5
这里写图片描述
2.最短剩余时间优先
A.4-0=4
B.20-1=19
C.12-2=20
D.7-4=3
Average:(4+19+20+3)/4 = 11.5
这里写图片描述
3.轮转调度算法,时间片3秒
A. 13-0=13
B.19-1 = 18
C.17-2 = 15
D.12-4 = 8
Average:(13+18+15+8)/4=13.5
这里写图片描述
4.优先级调度,非抢占式
A。4-0=4
B.20-1=19
C.9-2=7
D.12-4=8
Average:(4+19+7+8)/4=9.5
这里写图片描述
3.关于死锁的常规题,不做细讲
request
A 0 2 0
B 4 1 2
C 3 0 2
D 1 1 0
A runs
x>=2
available 2 x 1
D runs
x>=1
available 3 x 3
C runs
x>=0
available 4 x 3
B runs
x>=1
available 5 x+1 3
4.电脑室有2m台电脑。 有2n名学生参加电脑课。 他们必须遵守:
1)房间只有一个入口。 他们进来,出来,每次只能由一个学生使用
2)一台电脑只能由一名学生使用,老师不使用电脑
3)当学生做完了实验时,他(她)可以离开房间
请描述使用机房的过程

Semaphore mutex=1;//出入实验室的信号量Semaphore T=1;//申请教师检查信号量Semaphore s=2m;//实验室机器数量信号量Lab_using(){  P(s);//申请实验机器  P(mutex);//进入实验室  Come into the lab_room();  V(mutex);  Find a computer to do the computing  experiment over();  while(true){    P(T);//请求教师检查    if(the teacher test the result right){//若检查后实验结果正确      V(T);//释放教师检查      P(mutex);//离开实验室      Go out the lab_room();      V(mutex);      Break;//跳出循环    }    else V(T);//实验结果错误,释放教师    Redo the computing experiment over();//重做实验  }V(s);//释放机器使用权限}
原创粉丝点击