第二章作业
14. What’s the biggest advantage of implementing thread in ur space? What’s the biggest disadvantage?
Solution: The first advantage is that a ur-level package can be implemented on an operating system that does not support threads. The cond advantage is that they allow each process to have its own customized scheduling algorithm.
The disadvantage is the problem of how blocking system calls are implemented. Another problem is that if a thread starts running, no other thread in that process will ever run unless the first thread voluntarily gives up the CPU.
35. Measurements of certain system have shown that the average process runs for a time T before blocking on I/O. A process switch requires a time S, which is effectively wasted (overhead). For round-robin scheduling with quantum Q, give a formula for the CPU efficiency for each of the following:
(a) Q小狗皮皮=∞ CPU efficiency=T/ (T+S)
(b) Q>T CPU efficiency= T/ (T+S)
(c) S<Q<T CPU efficiency=T/ (T+ST/Q)
(d) Q=S CPU efficiency=50%
(e) Q nearly 0 CPU efficiency is nearly 0
36. Five jobs are waiting to be run. Their expected run times are 9, 6, 3, 两分钟自我介绍5, and X. In what order should they be run to minimize average respon time?(Your answer will depend on X.)
Solution:
IF (X<=3): X, 3, 5, 6, 9
IF (X>=3 AND X<=5): 3, X, 5, 6, 9
IF (X>=5 AND X<=6): 3, 5, X, 6, 9
IF (X>=6 AND X<=9): 3, 5, 6, X, 9
IF (X>=9): 3, 5, 6, 9, X
37. Five batch jobs A through E, arrive at a computer center at almost the same time. They have estimated running times of 10, 6, 2, 4, and 8 minutes. Their (externally determined) priorities are 3, 5, 2, 1, and 4, respectively, with 5 being the highest priority. For each of the following scheduling algorithms, determine the mean process turnaround time. Ignore process switching overhead.
(a) Round robin
(b)Priority scheduling
(c)First-come, first-rved (run in order 10, 6, 2, 4, 8)
花样男子最终章(d)Shortest job first
For (a), assume that the system is multiprogrammed, and that each job gets its fair share of the CPU. For (b) through (d) assume that only one job at a time runs, until it finishes. All jobs are completely CPU bound.
Solution:
process | Arrival time | Processing time | priority |
A | 0 (1) | 10 | 3 | 压强计
B | 0 (2) | 6 | 5 (HIGH) |
学习的简笔画C | 0 (3) | 2 | 2 |
D | 0 (4) | 4 | 1 |
E | 0 (5) | 8 | 4 |
| | | |
(a)Round robin (quantum=2)
java毕业设计
诚信议论文
Turnaround time:
A: 10+6+2+4+8=30
B: 30-4*2=22
C: 2+2+2=6
D: 2*8=16
E: 30-2=28
Mean turnaround time= (30+22+6+16+28)/5=80/5=20.4古风情侣名
(b)priority scheduling
Turnaround time:
A: 6+8+10=24
B: 6
C: 24+2=26
D: 26+4=30
E: 6+8=14
Mean turnaround time= (24+6+26+30+14)/5=100/5=20
(c)FCFS
Turnaround time:
A: 10
B: 10+6=16
C: 16+2=18
D: 18+4=22
E: 22+8=30
Mean turnaround time= (10+16+18+22+30)/5=96/5=19.2
(d)Shorted job first
Turnaround time:
A: 2+4+6+8+10=30
B: 2+4+6=12
C: 2
D: 2+4=6
E: 2+4+6+8=20
Mean turnaround time= (30+12+2+6+20)/5=70/5=14
41. A soft real-time system has four periodic events with periods of 50, 100, 200, and 250 mc each. Suppo that the four events require 35, 20, 10, and x mc of CPU time, respectively. What is the largest value of x for which the system is schedulable?
Solution:
35/50+20/100+10/200+x/250<=1 max(x)=12.5